Image encoding/decoding method and device for performing prof, and method for transmitting bitstream

ABSTRACT

An image encoding/decoding method and apparatus are provided. An image decoding method according to the present disclosure is performed by an image decoding apparatus. The image decoding method comprises deriving a prediction sample of a current block based on motion information of the current block, deriving a reference picture resampling (RPR) condition for the current block, determining whether prediction refinement with optical flow (PROF) applies to the current block based on the RPR condition, and deriving a refined prediction sample for the current block by applying PROF to the current block.

TECHNICAL FIELD

The present disclosure relates to an image encoding/decoding method andapparatus and a method of transmitting a bitstream, and, moreparticularly, to an image encoding/decoding method and apparatus forperforming prediction refinement with optical flow (PROF), and a methodof transmitting a bitstream generated by the image encodingmethod/apparatus of the present disclosure.

BACKGROUND ART

Recently, demand for high-resolution and high-quality images such ashigh definition (HD) images and ultra high definition (UHD) images isincreasing in various fields. As resolution and quality of image dataare improved, the amount of transmitted information or bits relativelyincreases as compared to existing image data. An increase in the amountof transmitted information or bits causes an increase in transmissioncost and storage cost.

Accordingly, there is a need for high-efficient image compressiontechnology for effectively transmitting, storing and reproducinginformation on high-resolution and high-quality images.

DISCLOSURE Technical Problem

An object of the present disclosure is to provide an imageencoding/decoding method and apparatus with improved encoding/decodingefficiency.

Another object of the present disclosure is to provide an imageencoding/decoding method and apparatus for performing PROF.

Another object of the present disclosure is to provide an imageencoding/decoding method and apparatus for performing PROF inconsideration of a size of a current picture and a size of a referencepicture.

Another object of the present disclosure is to provide a method oftransmitting a bitstream generated by an image encoding method orapparatus according to the present disclosure.

Another object of the present disclosure is to provide a recordingmedium storing a bitstream generated by an image encoding method orapparatus according to the present disclosure.

Another object of the present disclosure is to provide a recordingmedium storing a bitstream received, decoded and used to reconstruct animage by an image decoding apparatus according to the presentdisclosure.

The technical problems solved by the present disclosure are not limitedto the above technical problems and other technical problems which arenot described herein will become apparent to those skilled in the artfrom the following description.

Technical Solution

An image decoding method according to an aspect of the presentdisclosure may comprise deriving a prediction sample of a current blockbased on motion information of the current block, deriving a referencepicture resampling (RPR) condition for the current block, determiningwhether prediction refinement with optical flow (PROF) applies to thecurrent block based on the RPR condition, and deriving a refinedprediction sample for the current block by applying PROF to the currentblock.

In the image decoding method of the present disclosure, the RPRcondition may be determined based on a size of a reference picture ofthe current block and a size of a current picture.

In the image decoding method of the present disclosure, the RPRcondition may be derived as a first value, based on the size of thereference picture of the current block being different from that of thecurrent picture, and the RPR condition may be derived as a second value,based on the size of the reference picture of the current block beingequal to that of the current picture.

In the image decoding method of the present disclosure, it may bedetermined that PROF does not apply to the current block, based on theRPR condition being the first value.

In the image decoding method of the present disclosure, whether PROFapplies to the current block may be determined based on a size of thecurrent block.

In the image decoding method of the present disclosure, it may bedetermined that PROF does not apply to the current block, based on aproduct of a width w of the current block and a height h of the currentblock being less than 128.

In the image decoding method of the present disclosure, informationspecifying whether the current block is an affine merge mode be parsedfrom a bitstream based on a size of the current block.

In the image decoding method of the present disclosure, the informationspecifying whether the current block is the affine merge mode may beparsed from the bitstream, based on each of a width w of the currentblock and a height h of the current block being equal to or greater than8 and w*h being equal to or greater than 128.

In the image decoding method of the present disclosure, informationspecifying whether the current block is an affine MVP mode may be parsedfrom a bitstream based on a size of the current block.

In the image decoding method of the present disclosure, the informationspecifying whether the current block is the affine MVP mode may beparsed from the bitstream, based on each of a width w of the currentblock and a height h of the current block being equal to or greater than8 and w*h being equal to or greater than 128.

In the image decoding method of the present disclosure, whether PROFapplies to the current block may be determined based on whether BCW orWP applies to the current block.

In the image decoding method of the present disclosure, it may bedetermined that PROF does not apply to the current block, based on BCWor WP applying to the current block.

An image decoding apparatus according to another aspect of the presentdisclosure may comprise a memory and at least one processor. The atleast one processor may derive a prediction sample of a current blockbased on motion information of the current block, derive a referencepicture resampling (RPR) condition for the current block, determinewhether prediction refinement with optical flow (PROF) applies to thecurrent block based on the RPR condition, and derive a refinedprediction sample for the current block by applying PROF to the currentblock.

An image encoding method according to another aspect of the presentdisclosure may comprise deriving a prediction sample of a current blockbased on motion information of the current block, deriving a referencepicture resampling (RPR) condition for the current block, determiningwhether prediction refinement with optical flow (PROF) applies to thecurrent block based on the RPR condition, and deriving a refinedprediction sample for the current block by applying PROF to the currentblock.

A transmission method according to another aspect of the presentdisclosure may transmit a bitstream generated by the image encodingmethod and/or the image encoding apparatus of the present disclosure toan image decoding apparatus.

In addition, a computer-readable recording medium according to anotheraspect of the present disclosure may store the bitstream generated bythe image encoding apparatus or the image encoding method of the presentdisclosure.

The features briefly summarized above with respect to the presentdisclosure are merely exemplary aspects of the detailed descriptionbelow of the present disclosure, and do not limit the scope of thepresent disclosure.

Advantageous Effects

According to the present disclosure, it is possible to provide an imageencoding/decoding method and apparatus with improved encoding/decodingefficiency.

Also, according to the present disclosure, it is possible to provide animage encoding/decoding method and apparatus for performing PROF.

Also, according to the present disclosure, it is possible to provide animage encoding/decoding method and apparatus for performing PROF inconsideration of a size of a current picture and a size of a referencepicture.

Also, according to the present disclosure, it is possible to provide amethod of transmitting a bitstream generated by an image encoding methodor apparatus according to the present disclosure.

Also, according to the present disclosure, it is possible to provide arecording medium storing a bitstream generated by an image encodingmethod or apparatus according to the present disclosure.

Also, according to the present disclosure, it is possible to provide arecording medium storing a bitstream received, decoded and used toreconstruct an image by an image decoding apparatus according to thepresent disclosure.

It will be appreciated by persons skilled in the art that that theeffects that can be achieved through the present disclosure are notlimited to what has been particularly described hereinabove and otheradvantages of the present disclosure will be more clearly understoodfrom the detailed description.

DESCRIPTION OF DRAWINGS

FIG. 1 is a view schematically illustrating a video coding system, towhich an embodiment of the present disclosure is applicable.

FIG. 2 is a view schematically illustrating an image encoding apparatus,to which an embodiment of the present disclosure is applicable.

FIG. 3 is a view schematically illustrating an image decoding apparatus,to which an embodiment of the present disclosure is applicable.

FIG. 4 is a flowchart illustrating an inter prediction based video/imageencoding method.

FIG. 5 is a view illustrating the configuration of an inter predictionunit 180 according to the present disclosure.

FIG. 6 is a flowchart illustrating an inter prediction based video/imagedecoding method.

FIG. 7 is a view illustrating the configuration of an inter predictionunit 260 according to the present disclosure.

FIG. 8 is a view illustrating motion expressible in an affine mode.

FIG. 9 is a view illustrating a parameter model of an affine mode.

FIG. 10 is a view illustrating a method of generating an affine mergecandidate list.

FIG. 11 is a view illustrating a CPMV derived from a neighboring block.

FIG. 12 is a view illustrating neighboring blocks for deriving aninherited affine merge candidate.

FIG. 13 is a view illustrating neighboring blocks for deriving aconstructed affine merge candidate.

FIG. 14 is a view illustrating a method of generating an affine MVPcandidate list.

FIG. 15 is a view illustrating a neighboring block of a sub-block basedTMVP mode.

FIG. 16 is a view illustrating a method of deriving a motion vectorfield according to a sub-block based TMVP mode.

FIG. 17 is a view illustrating a CU extended to perform BDOF.

FIG. 18 is a view illustrating a relationship among Δv(i, j), v(i, j)and a subblock motion vector.

FIG. 19 is a view illustrating an example of a process of determiningwhether to apply BDOF according to the present disclosure.

FIG. 20 is a view illustrating an example of a process of determiningwhether to apply PROF according to the present disclosure.

FIG. 21 is a view illustrating signaling of information specifyingwhether to apply a subblock merge mode according to an example of thepresent disclosure.

FIG. 22 is a view illustrating signaling of information specifyingwhether to apply an affine MVP mode according to an embodiment of thepresent disclosure.

FIG. 23 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

FIG. 24 is a view illustrating signaling of information specifyingwhether to apply a subblock merge mode according to another embodimentof the present disclosure.

FIG. 25 is a view illustrating signaling of information specifyingwhether to apply an affine MVP mode according to another embodiment ofthe present disclosure.

FIG. 26 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

FIG. 27 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

FIG. 28 is a view illustrating a method of performing PROF according tothe present disclosure.

FIG. 29 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

FIG. 30 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

FIG. 31 is a view showing a content streaming system, to which anembodiment of the present disclosure is applicable.

MODE FOR INVENTION

Hereinafter, the embodiments of the present disclosure will be describedin detail with reference to the accompanying drawings so as to be easilyimplemented by those skilled in the art. However, the present disclosuremay be implemented in various different forms, and is not limited to theembodiments described herein.

In describing the present disclosure, if it is determined that thedetailed description of a related known function or construction rendersthe scope of the present disclosure unnecessarily ambiguous, thedetailed description thereof will be omitted. In the drawings, parts notrelated to the description of the present disclosure are omitted, andsimilar reference numerals are attached to similar parts.

In the present disclosure, when a component is “connected”, “coupled” or“linked” to another component, it may include not only a directconnection relationship but also an indirect connection relationship inwhich an intervening component is present. In addition, when a component“includes” or “has” other components, it means that other components maybe further included, rather than excluding other components unlessotherwise stated.

In the present disclosure, the terms first, second, etc. may be usedonly for the purpose of distinguishing one component from othercomponents, and do not limit the order or importance of the componentsunless otherwise stated. Accordingly, within the scope of the presentdisclosure, a first component in one embodiment may be referred to as asecond component in another embodiment, and similarly, a secondcomponent in one embodiment may be referred to as a first component inanother embodiment.

In the present disclosure, components that are distinguished from eachother are intended to clearly describe each feature, and do not meanthat the components are necessarily separated. That is, a plurality ofcomponents may be integrated and implemented in one hardware or softwareunit, or one component may be distributed and implemented in a pluralityof hardware or software units. Therefore, even if not stated otherwise,such embodiments in which the components are integrated or the componentis distributed are also included in the scope of the present disclosure.

In the present disclosure, the components described in variousembodiments do not necessarily mean essential components, and somecomponents may be optional components. Accordingly, an embodimentconsisting of a subset of components described in an embodiment is alsoincluded in the scope of the present disclosure. In addition,embodiments including other components in addition to componentsdescribed in the various embodiments are included in the scope of thepresent disclosure.

The present disclosure relates to encoding and decoding of an image, andterms used in the present disclosure may have a general meaning commonlyused in the technical field, to which the present disclosure belongs,unless newly defined in the present disclosure.

In the present disclosure, a “picture” generally refers to a unitrepresenting one image in a specific time period, and a slice/tile is acoding unit constituting a part of a picture, and one picture may becomposed of one or more slices/tiles. In addition, a slice/tile mayinclude one or more coding tree units (CTUs).

In the present disclosure, a “pixel” or a “pel” may mean a smallest unitconstituting one picture (or image). In addition, “sample” may be usedas a term corresponding to a pixel. A sample may generally represent apixel or a value of a pixel, and may represent only a pixel/pixel valueof a luma component or only a pixel/pixel value of a chroma component.

In the present disclosure, a “unit” may represent a basic unit of imageprocessing. The unit may include at least one of a specific region ofthe picture and information related to the region. The unit may be usedinterchangeably with terms such as “sample array”, “block” or “area” insome cases. In a general case, an M×N block may include samples (orsample arrays) or a set (or array) of transform coefficients of Mcolumns and N rows.

In the present disclosure, “current block” may mean one of “currentcoding block”, “current coding unit”, “coding target block”, “decodingtarget block” or “processing target block”. When prediction isperformed, “current block” may mean “current prediction block” or“prediction target block”. When transform (inversetransform)/quantization (dequantization) is performed, “current block”may mean “current transform block” or “transform target block”. Whenfiltering is performed, “current block” may mean “filtering targetblock”.

In the present disclosure, the term “/” and “,” should be interpreted toindicate “and/or.” For instance, the expression “A/B” and “A, B” maymean “A and/or B.” Further, “A/B/C” and “A/B/C” may mean “at least oneof A, B, and/or C.”

In the present disclosure, the term “or” should be interpreted toindicate “and/or.” For instance, the expression “A or B” may comprise 1)only “A”, 2) only “B”, and/or 3) both “A and B”. In other words, in thepresent disclosure, the term “or” should be interpreted to indicate“additionally or alternatively.”

Overview of Video Coding System

FIG. 1 is a view showing a video coding system according to the presentdisclosure.

The video coding system according to an embodiment may include aencoding apparatus 10 and a decoding apparatus 20. The encodingapparatus 10 may deliver encoded video and/or image information or datato the decoding apparatus 20 in the form of a file or streaming via adigital storage medium or network.

The encoding apparatus 10 according to an embodiment may include a videosource generator 11, an encoding unit 12 and a transmitter 13. Thedecoding apparatus 20 according to an embodiment may include a receiver21, a decoding unit 22 and a renderer 23. The encoding unit 12 may becalled a video/image encoding unit, and the decoding unit 22 may becalled a video/image decoding unit. The transmitter 13 may be includedin the encoding unit 12. The receiver 21 may be included in the decodingunit 22. The renderer 23 may include a display and the display may beconfigured as a separate device or an external component.

The video source generator 11 may acquire a video/image through aprocess of capturing, synthesizing or generating the video/image. Thevideo source generator 11 may include a video/image capture deviceand/or a video/image generating device. The video/image capture devicemay include, for example, one or more cameras, video/image archivesincluding previously captured video/images, and the like. Thevideo/image generating device may include, for example, computers,tablets and smartphones, and may (electronically) generate video/images.For example, a virtual video/image may be generated through a computeror the like. In this case, the video/image capturing process may bereplaced by a process of generating related data.

The encoding unit 12 may encode an input video/image. The encoding unit12 may perform a series of procedures such as prediction, transform, andquantization for compression and coding efficiency. The encoding unit 12may output encoded data (encoded video/image information) in the form ofa bitstream.

The transmitter 13 may transmit the encoded video/image information ordata output in the form of a bitstream to the receiver 21 of thedecoding apparatus 20 through a digital storage medium or a network inthe form of a file or streaming. The digital storage medium may includevarious storage mediums such as USB, SD, CD, DVD, Blu-ray, HDD, SSD, andthe like. The transmitter 13 may include an element for generating amedia file through a predetermined file format and may include anelement for transmission through a broadcast/communication network. Thereceiver 21 may extract/receive the bitstream from the storage medium ornetwork and transmit the bitstream to the decoding unit 22.

The decoding unit 22 may decode the video/image by performing a seriesof procedures such as dequantization, inverse transform, and predictioncorresponding to the operation of the encoding unit 12.

The renderer 23 may render the decoded video/image. The renderedvideo/image may be displayed through the display.

Overview of Image Encoding Apparatus

FIG. 2 is a view schematically showing an image encoding apparatus, towhich an embodiment of the present disclosure is applicable.

As shown in FIG. 2 , the image encoding apparatus 100 may include animage partitioner 110, a subtractor 115, a transformer 120, a quantizer130, a dequantizer 140, an inverse transformer 150, an adder 155, afilter 160, a memory 170, an inter prediction unit 180, an intraprediction unit 185 and an entropy encoder 190. The inter predictionunit 180 and the intra prediction unit 185 may be collectively referredto as a “prediction unit”. The transformer 120, the quantizer 130, thedequantizer 140 and the inverse transformer 150 may be included in aresidual processor. The residual processor may further include thesubtractor 115.

All or at least some of the plurality of components configuring theimage encoding apparatus 100 may be configured by one hardware component(e.g., an encoder or a processor) in some embodiments. In addition, thememory 170 may include a decoded picture buffer (DPB) and may beconfigured by a digital storage medium.

The image partitioner 110 may partition an input image (or a picture ora frame) input to the image encoding apparatus 100 into one or moreprocessing units. For example, the processing unit may be called acoding unit (CU). The coding unit may be acquired by recursivelypartitioning a coding tree unit (CTU) or a largest coding unit (LCU)according to a quad-tree binary-tree ternary-tree (QT/BT/TT) structure.For example, one coding unit may be partitioned into a plurality ofcoding units of a deeper depth based on a quad tree structure, a binarytree structure, and/or a ternary structure. For partitioning of thecoding unit, a quad tree structure may be applied first and the binarytree structure and/or ternary structure may be applied later. The codingprocedure according to the present disclosure may be performed based onthe final coding unit that is no longer partitioned. The largest codingunit may be used as the final coding unit or the coding unit of deeperdepth acquired by partitioning the largest coding unit may be used asthe final coding unit. Here, the coding procedure may include aprocedure of prediction, transform, and reconstruction, which will bedescribed later. As another example, the processing unit of the codingprocedure may be a prediction unit (PU) or a transform unit (TU). Theprediction unit and the transform unit may be split or partitioned fromthe final coding unit. The prediction unit may be a unit of sampleprediction, and the transform unit may be a unit for deriving atransform coefficient and/or a unit for deriving a residual signal fromthe transform coefficient.

The prediction unit (the inter prediction unit 180 or the intraprediction unit 185) may perform prediction on a block to be processed(current block) and generate a predicted block including predictionsamples for the current block. The prediction unit may determine whetherintra prediction or inter prediction is applied on a current block or CUbasis. The prediction unit may generate various information related toprediction of the current block and transmit the generated informationto the entropy encoder 190. The information on the prediction may beencoded in the entropy encoder 190 and output in the form of abitstream.

The intra prediction unit 185 may predict the current block by referringto the samples in the current picture. The referred samples may belocated in the neighborhood of the current block or may be located apartaccording to the intra prediction mode and/or the intra predictiontechnique. The intra prediction modes may include a plurality ofnon-directional modes and a plurality of directional modes. Thenon-directional mode may include, for example, a DC mode and a planarmode. The directional mode may include, for example, 33 directionalprediction modes or 65 directional prediction modes according to thedegree of detail of the prediction direction. However, this is merely anexample, more or less directional prediction modes may be used dependingon a setting. The intra prediction unit 185 may determine the predictionmode applied to the current block by using a prediction mode applied toa neighboring block.

The inter prediction unit 180 may derive a predicted block for thecurrent block based on a reference block (reference sample array)specified by a motion vector on a reference picture. In this case, inorder to reduce the amount of motion information transmitted in theinter prediction mode, the motion information may be predicted in unitsof blocks, subblocks, or samples based on correlation of motioninformation between the neighboring block and the current block. Themotion information may include a motion vector and a reference pictureindex. The motion information may further include inter predictiondirection (L0 prediction, L1 prediction, Bi-prediction, etc.)information. In the case of inter prediction, the neighboring block mayinclude a spatial neighboring block present in the current picture and atemporal neighboring block present in the reference picture. Thereference picture including the reference block and the referencepicture including the temporal neighboring block may be the same ordifferent. The temporal neighboring block may be called a collocatedreference block, a co-located CU (colCU), and the like. The referencepicture including the temporal neighboring block may be called acollocated picture (colPic). For example, the inter prediction unit 180may configure a motion information candidate list based on neighboringblocks and generate information indicating which candidate is used toderive a motion vector and/or a reference picture index of the currentblock. Inter prediction may be performed based on various predictionmodes. For example, in the case of a skip mode and a merge mode, theinter prediction unit 180 may use motion information of the neighboringblock as motion information of the current block. In the case of theskip mode, unlike the merge mode, the residual signal may not betransmitted. In the case of the motion vector prediction (MVP) mode, themotion vector of the neighboring block may be used as a motion vectorpredictor, and the motion vector of the current block may be signaled byencoding a motion vector difference and an indicator for a motion vectorpredictor. The motion vector difference may mean a difference betweenthe motion vector of the current block and the motion vector predictor.

The prediction unit may generate a prediction signal based on variousprediction methods and prediction techniques described below. Forexample, the prediction unit may not only apply intra prediction orinter prediction but also simultaneously apply both intra prediction andinter prediction, in order to predict the current block. A predictionmethod of simultaneously applying both intra prediction and interprediction for prediction of the current block may be called combinedinter and intra prediction (CIIP). In addition, the prediction unit mayperform intra block copy (IBC) for prediction of the current block.Intra block copy may be used for content image/video coding of a game orthe like, for example, screen content coding (SCC). IBC is a method ofpredicting a current picture using a previously reconstructed referenceblock in the current picture at a location apart from the current blockby a predetermined distance. When IBC is applied, the location of thereference block in the current picture may be encoded as a vector (blockvector) corresponding to the predetermined distance.

The prediction signal generated by the prediction unit may be used togenerate a reconstructed signal or to generate a residual signal. Thesubtractor 115 may generate a residual signal (residual block orresidual sample array) by subtracting the prediction signal (predictedblock or prediction sample array) output from the prediction unit fromthe input image signal (original block or original sample array). Thegenerated residual signal may be transmitted to the transformer 120.

The transformer 120 may generate transform coefficients by applying atransform technique to the residual signal. For example, the transformtechnique may include at least one of a discrete cosine transform (DCT),a discrete sine transform (DST), a karhunen-loeve transform (KLT), agraph-based transform (GBT), or a conditionally non-linear transform(CNT). Here, the GBT means transform obtained from a graph whenrelationship information between pixels is represented by the graph. TheCNT refers to transform acquired based on a prediction signal generatedusing all previously reconstructed pixels. In addition, the transformprocess may be applied to square pixel blocks having the same size ormay be applied to blocks having a variable size rather than square.

The quantizer 130 may quantize the transform coefficients and transmitthem to the entropy encoder 190. The entropy encoder 190 may encode thequantized signal (information on the quantized transform coefficients)and output a bitstream. The information on the quantized transformcoefficients may be referred to as residual information. The quantizer130 may rearrange quantized transform coefficients in a block form intoa one-dimensional vector form based on a coefficient scanning order andgenerate information on the quantized transform coefficients based onthe quantized transform coefficients in the one-dimensional vector form.

The entropy encoder 190 may perform various encoding methods such as,for example, exponential Golomb, context-adaptive variable length coding(CAVLC), context-adaptive binary arithmetic coding (CABAC), and thelike. The entropy encoder 190 may encode information necessary forvideo/image reconstruction other than quantized transform coefficients(e.g., values of syntax elements, etc.) together or separately. Encodedinformation (e.g., encoded video/image information) may be transmittedor stored in units of network abstraction layers (NALs) in the form of abitstream. The video/image information may further include informationon various parameter sets such as an adaptation parameter set (APS), apicture parameter set (PPS), a sequence parameter set (SPS), or a videoparameter set (VPS). In addition, the video/image information mayfurther include general constraint information. The signaledinformation, transmitted information and/or syntax elements described inthe present disclosure may be encoded through the above-describedencoding procedure and included in the bitstream.

The bitstream may be transmitted over a network or may be stored in adigital storage medium. The network may include a broadcasting networkand/or a communication network, and the digital storage medium mayinclude various storage media such as USB, SD, CD, DVD, Blu-ray, HDD,SSD, and the like. A transmitter (not shown) transmitting a signaloutput from the entropy encoder 190 and/or a storage unit (not shown)storing the signal may be included as internal/external element of theimage encoding apparatus 100. Alternatively, the transmitter may beprovided as the component of the entropy encoder 190.

The quantized transform coefficients output from the quantizer 130 maybe used to generate a residual signal. For example, the residual signal(residual block or residual samples) may be reconstructed by applyingdequantization and inverse transform to the quantized transformcoefficients through the dequantizer 140 and the inverse transformer150.

The adder 155 adds the reconstructed residual signal to the predictionsignal output from the inter prediction unit 180 or the intra predictionunit 185 to generate a reconstructed signal (reconstructed picture,reconstructed block, reconstructed sample array). If there is noresidual for the block to be processed, such as a case where the skipmode is applied, the predicted block may be used as the reconstructedblock. The adder 155 may be called a reconstructor or a reconstructedblock generator. The generated reconstructed signal may be used forintra prediction of a next block to be processed in the current pictureand may be used for inter prediction of a next picture through filteringas described below.

Meanwhile, as described below, luma mapping with chroma scaling (LMCS)is applicable in a picture encoding process.

The filter 160 may improve subjective/objective image quality byapplying filtering to the reconstructed signal. For example, the filter160 may generate a modified reconstructed picture by applying variousfiltering methods to the reconstructed picture and store the modifiedreconstructed picture in the memory 170, specifically, a DPB of thememory 170. The various filtering methods may include, for example,deblocking filtering, a sample adaptive offset, an adaptive loop filter,a bilateral filter, and the like. The filter 160 may generate variousinformation related to filtering and transmit the generated informationto the entropy encoder 190 as described later in the description of eachfiltering method. The information related to filtering may be encoded bythe entropy encoder 190 and output in the form of a bitstream.

The modified reconstructed picture transmitted to the memory 170 may beused as the reference picture in the inter prediction unit 180. Wheninter prediction is applied through the image encoding apparatus 100,prediction mismatch between the image encoding apparatus 100 and theimage decoding apparatus may be avoided and encoding efficiency may beimproved.

The DPB of the memory 170 may store the modified reconstructed picturefor use as a reference picture in the inter prediction unit 180. Thememory 170 may store the motion information of the block from which themotion information in the current picture is derived (or encoded) and/orthe motion information of the blocks in the picture that have alreadybeen reconstructed. The stored motion information may be transmitted tothe inter prediction unit 180 and used as the motion information of thespatial neighboring block or the motion information of the temporalneighboring block. The memory 170 may store reconstructed samples ofreconstructed blocks in the current picture and may transfer thereconstructed samples to the intra prediction unit 185.

Overview of Image Decoding Apparatus

FIG. 3 is a view schematically showing an image decoding apparatus, towhich an embodiment of the present disclosure is applicable.

As shown in FIG. 3 , the image decoding apparatus 200 may include anentropy decoder 210, a dequantizer 220, an inverse transformer 230, anadder 235, a filter 240, a memory 250, an inter prediction unit 260 andan intra prediction unit 265. The inter prediction unit 260 and theintra prediction unit 265 may be collectively referred to as a“prediction unit”. The dequantizer 220 and the inverse transformer 230may be included in a residual processor.

All or at least some of a plurality of components configuring the imagedecoding apparatus 200 may be configured by a hardware component (e.g.,a decoder or a processor) according to an embodiment. In addition, thememory 250 may include a decoded picture buffer (DPB) or may beconfigured by a digital storage medium.

The image decoding apparatus 200, which has received a bitstreamincluding video/image information, may reconstruct an image byperforming a process corresponding to a process performed by the imageencoding apparatus 100 of FIG. 2 . For example, the image decodingapparatus 200 may perform decoding using a processing unit applied inthe image encoding apparatus. Thus, the processing unit of decoding maybe a coding unit, for example. The coding unit may be acquired bypartitioning a coding tree unit or a largest coding unit. Thereconstructed image signal decoded and output through the image decodingapparatus 200 may be reproduced through a reproducing apparatus (notshown).

The image decoding apparatus 200 may receive a signal output from theimage encoding apparatus of FIG. 2 in the form of a bitstream. Thereceived signal may be decoded through the entropy decoder 210. Forexample, the entropy decoder 210 may parse the bitstream to deriveinformation (e.g., video/image information) necessary for imagereconstruction (or picture reconstruction). The video/image informationmay further include information on various parameter sets such as anadaptation parameter set (APS), a picture parameter set (PPS), asequence parameter set (SPS), or a video parameter set (VPS). Inaddition, the video/image information may further include generalconstraint information. The image decoding apparatus may further decodepicture based on the information on the parameter set and/or the generalconstraint information. Signaled/received information and/or syntaxelements described in the present disclosure may be decoded through thedecoding procedure and obtained from the bitstream. For example, theentropy decoder 210 decodes the information in the bitstream based on acoding method such as exponential Golomb coding, CAVLC, or CABAC, andoutput values of syntax elements required for image reconstruction andquantized values of transform coefficients for residual. Morespecifically, the CABAC entropy decoding method may receive a bincorresponding to each syntax element in the bitstream, determine acontext model using a decoding target syntax element information,decoding information of a neighboring block and a decoding target blockor information of a symbol/bin decoded in a previous stage, and performarithmetic decoding on the bin by predicting a probability of occurrenceof a bin according to the determined context model, and generate asymbol corresponding to the value of each syntax element. In this case,the CABAC entropy decoding method may update the context model by usingthe information of the decoded symbol/bin for a context model of a nextsymbol/bin after determining the context model. The information relatedto the prediction among the information decoded by the entropy decoder210 may be provided to the prediction unit (the inter prediction unit260 and the intra prediction unit 265), and the residual value on whichthe entropy decoding was performed in the entropy decoder 210, that is,the quantized transform coefficients and related parameter information,may be input to the dequantizer 220. In addition, information onfiltering among information decoded by the entropy decoder 210 may beprovided to the filter 240. Meanwhile, a receiver (not shown) forreceiving a signal output from the image encoding apparatus may befurther configured as an internal/external element of the image decodingapparatus 200, or the receiver may be a component of the entropy decoder210.

Meanwhile, the image decoding apparatus according to the presentdisclosure may be referred to as a video/image/picture decodingapparatus. The image decoding apparatus may be classified into aninformation decoder (video/image/picture information decoder) and asample decoder (video/image/picture sample decoder). The informationdecoder may include the entropy decoder 210. The sample decoder mayinclude at least one of the dequantizer 220, the inverse transformer230, the adder 235, the filter 240, the memory 250, the inter predictionunit 260 or the intra prediction unit 265.

The dequantizer 220 may dequantize the quantized transform coefficientsand output the transform coefficients. The dequantizer 220 may rearrangethe quantized transform coefficients in the form of a two-dimensionalblock. In this case, the rearrangement may be performed based on thecoefficient scanning order performed in the image encoding apparatus.The dequantizer 220 may perform dequantization on the quantizedtransform coefficients by using a quantization parameter (e.g.,quantization step size information) and obtain transform coefficients.

The inverse transformer 230 may inversely transform the transformcoefficients to obtain a residual signal (residual block, residualsample array).

The prediction unit may perform prediction on the current block andgenerate a predicted block including prediction samples for the currentblock. The prediction unit may determine whether intra prediction orinter prediction is applied to the current block based on theinformation on the prediction output from the entropy decoder 210 andmay determine a specific intra/inter prediction mode (predictiontechnique).

It is the same as described in the prediction unit of the image encodingapparatus 100 that the prediction unit may generate the predictionsignal based on various prediction methods (techniques) which will bedescribed later.

The intra prediction unit 265 may predict the current block by referringto the samples in the current picture. The description of the intraprediction unit 185 is equally applied to the intra prediction unit 265.

The inter prediction unit 260 may derive a predicted block for thecurrent block based on a reference block (reference sample array)specified by a motion vector on a reference picture. In this case, inorder to reduce the amount of motion information transmitted in theinter prediction mode, motion information may be predicted in units ofblocks, subblocks, or samples based on correlation of motion informationbetween the neighboring block and the current block. The motioninformation may include a motion vector and a reference picture index.The motion information may further include inter prediction direction(L0 prediction, L1 prediction, Bi-prediction, etc.) information. In thecase of inter prediction, the neighboring block may include a spatialneighboring block present in the current picture and a temporalneighboring block present in the reference picture. For example, theinter prediction unit 260 may configure a motion information candidatelist based on neighboring blocks and derive a motion vector of thecurrent block and/or a reference picture index based on the receivedcandidate selection information. Inter prediction may be performed basedon various prediction modes, and the information on the prediction mayinclude information indicating a mode of inter prediction for thecurrent block.

The adder 235 may generate a reconstructed signal (reconstructedpicture, reconstructed block, reconstructed sample array) by adding theobtained residual signal to the prediction signal (predicted block,predicted sample array) output from the prediction unit (including theinter prediction unit 260 and/or the intra prediction unit 265). Thedescription of the adder 155 is equally applicable to the adder 235.

Meanwhile, as described below, luma mapping with chroma scaling (LMCS)is applicable in a picture decoding process.

The filter 240 may improve subjective/objective image quality byapplying filtering to the reconstructed signal. For example, the filter240 may generate a modified reconstructed picture by applying variousfiltering methods to the reconstructed picture and store the modifiedreconstructed picture in the memory 250, specifically, a DPB of thememory 250. The various filtering methods may include, for example,deblocking filtering, a sample adaptive offset, an adaptive loop filter,a bilateral filter, and the like.

The (modified) reconstructed picture stored in the DPB of the memory 250may be used as a reference picture in the inter prediction unit 260. Thememory 250 may store the motion information of the block from which themotion information in the current picture is derived (or decoded) and/orthe motion information of the blocks in the picture that have alreadybeen reconstructed. The stored motion information may be transmitted tothe inter prediction unit 260 so as to be utilized as the motioninformation of the spatial neighboring block or the motion informationof the temporal neighboring block. The memory 250 may storereconstructed samples of reconstructed blocks in the current picture andtransfer the reconstructed samples to the intra prediction unit 265.

In the present disclosure, the embodiments described in the filter 160,the inter prediction unit 180, and the intra prediction unit 185 of theimage encoding apparatus 100 may be equally or correspondingly appliedto the filter 240, the inter prediction unit 260, and the intraprediction unit 265 of the image decoding apparatus 200.

Overview of Inter Prediction

An image encoding apparatus/image decoding apparatus may perform interprediction in units of blocks to derive a prediction sample. Interprediction may mean prediction derived in a manner that is dependent ondata elements of picture(s) other than a current picture. When interprediction applies to the current block, a predicted block for thecurrent block may be derived based on a reference block specified by amotion vector on a reference picture.

In this case, in order to reduce the amount of motion informationtransmitted in an inter prediction mode, motion information of thecurrent block may be derived based on correlation of motion informationbetween a neighboring block and the current block, and motioninformation may be derived in units of blocks, subblocks or samples. Themotion information may include a motion vector and a reference pictureindex. The motion information may further include inter prediction typeinformation. Here, the inter prediction type information may meandirectional information of inter prediction. The inter prediction typeinformation may indicate that a current block is predicted using one ofL0 prediction, L1 prediction or Bi-prediction.

When applying inter prediction to the current block, the neighboringblock of the current block may include a spatial neighboring blockpresent in the current picture and a temporal neighboring block presentin the reference picture. A reference picture including the referenceblock for the current block and a reference picture including thetemporal neighboring block may be the same or different. The temporalneighboring block may be referred to as a collocated reference block orcollocated CU (colCU), and the reference picture including the temporalneighboring block may be referred to as a collocated picture (colPic).

Meanwhile, a motion information candidate list may be constructed basedon the neighboring blocks of the current block, and, in this case, flagor index information indicating which candidate is used may be signaledin order to derive the motion vector of the current block and/or thereference picture index.

The motion information may include L0 motion information and/or L1motion information according to the inter prediction type. The motionvector in an L0 direction may be defined as an L0 motion vector or MVL0,and the motion vector in an L1 direction may be defined as an L1 motionvector or MVL1. Prediction based on the L0 motion vector may be definedas L0 prediction, prediction based on the L1 motion vector may bedefined as L1 prediction, and prediction based both the L0 motion vectorand the L1 motion vector may be defined as Bi-prediction. Here, the L0motion vector may mean a motion vector associated with a referencepicture list L0 and the L1 motion vector may mean a motion vectorassociated with a reference picture list L1.

The reference picture list L0 may include pictures before the currentpicture in output order as reference pictures, and the reference picturelist L1 may include pictures after the current picture in output order.The previous pictures may be defined as forward (reference) pictures andthe subsequent pictures may be defined as backward (reference) pictures.Meanwhile, the reference picture list L0 may further include picturesafter the current picture in output order as reference pictures. In thiscase, within the reference picture list L0, the previous pictures may befirst indexed and the subsequent pictures may then be indexed. Thereference picture list L1 may further include pictures before thecurrent picture in output order as reference pictures. In this case,within the reference picture list L1, the subsequent pictures may befirst indexed and the previous pictures may then be indexed. Here, theoutput order may correspond to picture order count (POC) order.

FIG. 4 is a flowchart illustrating an inter prediction based video/imageencoding method.

FIG. 5 is a view illustrating the configuration of an inter predictor180 according to the present disclosure.

The encoding method of FIG. 6 may be performed by the image encodingapparatus of FIG. 2 . Specifically, step S410 may be performed by theinter predictor 180, and step S420 may be performed by the residualprocessor. Specifically, step S420 may be performed by the subtractor115. Step S430 may be performed by the entropy encoder 190. Theprediction information of step S630 may be derived by the interpredictor 180, and the residual information of step S630 may be derivedby the residual processor. The residual information is information onthe residual samples. The residual information may include informationon quantized transform coefficients for the residual samples. Asdescribed above, the residual samples may be derived as transformcoefficients through the transformer 120 of the image encodingapparatus, and the transform coefficient may be derived as quantizedtransform coefficients through the quantizer 130. Information on thequantized transform coefficients may be encoded by the entropy encoder190 through a residual coding procedure.

The image encoding apparatus may perform inter prediction with respectto a current block (S410). The image encoding apparatus may derive aninter prediction mode and motion information of the current block andgenerate prediction samples of the current block. Here, inter predictionmode determination, motion information derivation and prediction samplesgeneration procedures may be simultaneously performed or any one thereofmay be performed before the other procedures. For example, as shown inFIG. 5 , the inter prediction unit 180 of the image encoding apparatusmay include a prediction mode determination unit 181, a motioninformation derivation unit 182 and a prediction sample derivation unit183. The prediction mode determination unit 181 may determine theprediction mode of the current block, the motion information derivationunit 182 may derive the motion information of the current block, and theprediction sample derivation unit 183 may derive the prediction samplesof the current block. For example, the inter prediction unit 180 of theimage encoding apparatus may search for a block similar to the currentblock within a predetermined area (search area) of reference picturesthrough motion estimation, and derive a reference block whose differencefrom the current block is equal to or less than a predeterminedcriterion or a minimum. Based on this, a reference picture indexindicating a reference picture in which the reference block is locatedmay be derived, and a motion vector may be derived based on a positiondifference between the reference block and the current block. The imageencoding apparatus may determine a mode applying to the current blockamong various inter prediction modes. The image encoding apparatus maycompare rate-distortion (RD) costs for the various prediction modes anddetermine an optimal inter prediction mode of the current block.However, the method of determining the inter prediction mode of thecurrent block by the image encoding apparatus is not limited to theabove example, and various methods may be used.

For example, the inter prediction mode of the current block may bedetermined to be at least one of a merge mode, a merge skip mode, amotion vector prediction (MVP) mode, a symmetric motion vectordifference (SMVD) mode, an affine mode, a subblock-based merge mode, anadaptive motion vector resolution (AMVR) mode, a history-based motionvector predictor (HMVP) mode, a pair-wise average merge mode, a mergemode with motion vector differences (MMVD) mode, a decoder side motionvector refinement (DMVR) mode, a combined inter and intra prediction(CIIP) mode or a geometric partitioning mode (GPM).

For example, when a skip mode or a merge mode applies to the currentblock, the image encoding apparatus may derive merge candidates fromneighboring blocks of the current block and construct a merge candidatelist using the derived merge candidates. In addition, the image encodingapparatus may derive a reference block whose difference from the currentblock is equal to or less than a predetermined criterion or a minimum,among reference blocks indicated by merge candidates included in themerge candidate list. In this case, a merge candidate associated withthe derived reference block may be selected, and merge index informationindicating the selected merge candidate may be generated and signaled toan image decoding apparatus. The motion information of the current blockmay be derived using the motion information of the selected mergecandidate.

As another example, when an MVP mode applies to the current block, theimage encoding apparatus may derive motion vector predictor (MVP)candidates from the neighboring blocks of the current block andconstruct an MVP candidate list using the derived MVP candidates. Inaddition, the image encoding apparatus may use the motion vector of theMVP candidate selected from among the MVP candidates included in the MVPcandidate list as the MVP of the current block. In this case, forexample, the motion vector indicating the reference block derived by theabove-described motion estimation may be used as the motion vector ofthe current block, an MVP candidate with a motion vector having asmallest difference from the motion vector of the current block amongthe MVP candidates may be the selected MVP candidate. A motion vectordifference (MVD) which is a difference obtained by subtracting the MVPfrom the motion vector of the current block may be derived. In thiscase, index information indicating the selected MVP candidate andinformation on the MVD may be signaled to the image decoding apparatus.In addition, when applying the MVP mode, the value of the referencepicture index may be constructed as reference picture index informationand separately signaled to the image decoding apparatus.

The image encoding apparatus may derive residual samples based on theprediction samples (S420). The image encoding apparatus may derive theresidual samples through comparison between original samples of thecurrent block and the prediction samples. For example, the residualsample may be derived by subtracting a corresponding prediction samplefrom an original sample.

The image encoding apparatus may encode image information includingprediction information and residual information (S430). The imageencoding apparatus may output the encoded image information in the formof a bitstream. The prediction information may include prediction modeinformation (e.g., skip flag, merge flag or mode index, etc.) andinformation on motion information as information related to theprediction procedure. Among the prediction mode information, the skipflag indicates whether a skip mode applies to the current block, and themerge flag indicates whether the merge mode applies to the currentblock. Alternatively, the prediction mode information may indicate oneof a plurality of prediction modes, such as a mode index. When the skipflag and the merge flag are 0, it may be determined that the MVP modeapplies to the current block. The information on the motion informationmay include candidate selection information (e.g., merge index, mvp flagor mvp index) which is information for deriving a motion vector. Amongthe candidate selection information, the merge index may be signaledwhen the merge mode applies to the current block and may be informationfor selecting one of merge candidates included in a merge candidatelist. Among the candidate selection information, the MVP flag or the MVPindex may be signaled when the MVP mode applies to the current block andmay be information for selecting one of MVP candidates in an MVPcandidate list. Specifically, the MVP flag may be signaled using asyntax element mvp_l0_flag or mvp_l1_flag. In addition, the informationon the motion information may include information on the above-describedMVD and/or reference picture index information. In addition, theinformation on the motion information may include information indicatingwhether to apply L0 prediction, L1 prediction or Bi-prediction. Theresidual information is information on the residual samples. Theresidual information may include information on quantized transformcoefficients for the residual samples.

The output bitstream may be stored in a (digital) storage medium andtransmitted to the image decoding apparatus or may be transmitted to theimage decoding apparatus via a network.

As described above, the image encoding apparatus may generate areconstructed picture (a picture including reconstructed samples and areconstructed block) based on the reference samples and the residualsamples. This is for the image encoding apparatus to derive the sameprediction result as that performed by the image decoding apparatus,thereby increasing coding efficiency. Accordingly, the image encodingapparatus may store the reconstructed picture (or the reconstructedsamples and the reconstructed block) in a memory and use the same as areference picture for inter prediction. As described above, an in-loopfiltering procedure is further applicable to the reconstructed picture.

FIG. 6 is a flowchart illustrating an inter prediction based video/imagedecoding method.

FIG. 7 is a view illustrating the configuration of an inter predictionunit 260 according to the present disclosure.

The image decoding apparatus may perform operation corresponding tooperation performed by the image encoding apparatus. The image decodingapparatus may perform prediction with respect to a current block basedon received prediction information and derive prediction samples.

The decoding method of FIG. 6 may be performed by the image decodingapparatus of FIG. 3 . Steps S610 to S630 may be performed by the interprediction unit 260, and the prediction information of step S610 and theresidual information of step S640 may be obtained from a bitstream bythe entropy decoder 210. The residual processor of the image decodingapparatus may derive residual samples for a current block based on theresidual information (S640). Specifically, the dequantizer 220 of theresidual processor may perform dequantization based on quantizedtransform coefficients derived based on the residual information toderive transform coefficients, and the inverse transformer 230 of theresidual processor may perform inverse transform with respect to thetransform coefficients to derive the residual samples for the currentblock. Step S650 may be performed by the adder 235 or the reconstructor.

Specifically, the image decoding apparatus may determine the predictionmode of the current block based on the received prediction information(S610). The image decoding apparatus may determine which interprediction mode applies to the current block based on the predictionmode information in the prediction information.

For example, it may be determined whether the skip mode applies to thecurrent block based on the skip flag. In addition, it may be determinedwhether the merge mode or the MVP mode applies to the current blockbased on the merge flag. Alternatively, one of various inter predictionmode candidates may be selected based on the mode index. The interprediction mode candidates may include a skip mode, a merge mode and/oran MVP mode or may include various inter prediction modes which will bedescribed below.

The image decoding apparatus may derive the motion information of thecurrent block based on the determined inter prediction mode (S620). Forexample, when the skip mode or the merge mode applies to the currentblock, the image decoding apparatus may construct a merge candidatelist, which will be described below, and select one of merge candidatesincluded in the merge candidate list. The selection may be performedbased on the above-described candidate selection information (mergeindex). The motion information of the current block may be derived usingthe motion information of the selected merge candidate. For example, themotion information of the selected merge candidate may be used as themotion information of the current block.

As another example, when the MVP mode applies to the current block, theimage decoding apparatus may construct an MVP candidate list and use themotion vector of an MVP candidate selected from among MVP candidatesincluded in the MVP candidate list as an MVP of the current block. Theselection may be performed based on the above-described candidateselection information (mvp flag or mvp index). In this case, the MVD ofthe current block may be derived based on information on the MVD, andthe motion vector of the current block may be derived based on MVP andMVD of the current block. In addition, the reference picture index ofthe current block may be derived based on the reference picture indexinformation. A picture indicated by the reference picture index in thereference picture list of the current block may be derived as areference picture referenced for inter prediction of the current block.

The image decoding apparatus may generate prediction samples of thecurrent block based on motion information of the current block (S630).In this case, the reference picture may be derived based on thereference picture index of the current block, and the prediction samplesof the current block may be derived using the samples of the referenceblock indicated by the motion vector of the current block on thereference picture. In some cases, a prediction sample filteringprocedure may be further performed with respect to all or some of theprediction samples of the current block.

For example, as shown in FIG. 7 , the inter prediction unit 260 of theimage decoding apparatus may include a prediction mode determinationunit 261, a motion information derivation unit 262 and a predictionsample derivation unit 263. In the inter prediction unit 260 of theimage decoding apparatus, the prediction mode determination unit 261 maydetermine the prediction mode of the current block based on the receivedprediction mode information, the motion information derivation unit 262may derive the motion information (a motion vector and/or a referencepicture index, etc.) of the current block based on the received motioninformation, and the prediction sample derivation unit 263 may derivethe prediction samples of the current block.

The image decoding apparatus may generate residual samples of thecurrent block based the received residual information (S640). The imagedecoding apparatus may generate the reconstructed samples of the currentblock based on the prediction samples and the residual samples andgenerate a reconstructed picture based on this (S650). Thereafter, anin-loop filtering procedure is applicable to the reconstructed pictureas described above.

As described above, the inter prediction procedure may include step ofdetermining an inter prediction mode, step of deriving motioninformation according to the determined prediction mode, and step ofperforming prediction (generating prediction samples) based on thederived motion information. The inter prediction procedure may beperformed by the image encoding apparatus and the image decodingapparatus, as described above.

Hereinafter, the step of deriving the motion information according tothe prediction mode will be described in greater detail.

As described above, inter prediction may be performed using motioninformation of a current block. An image encoding apparatus may deriveoptimal motion information of a current block through a motionestimation procedure. For example, the image encoding apparatus maysearch for a similar reference block with high correlation within apredetermined search range in the reference picture using an originalblock in an original picture for the current block in fractional pixelunit, and derive motion information using the same. Similarity of theblock may be calculated based on a sum of absolute differences (SAD)between the current block and the reference block. In this case, motioninformation may be derived based on a reference block with a smallestSAD in the search area. The derived motion information may be signaledto an image decoding apparatus according to various methods based on aninter prediction mode.

When a merge mode applies to a current block, motion information of thecurrent block is not directly transmitted and motion information of thecurrent block is derived using motion information of a neighboringblock. Accordingly, motion information of a current prediction block maybe indicated by transmitting flag information indicating that the mergemode is used and candidate selection information (e.g., a merge index)indicating which neighboring block is used as a merge candidate. In thepresent disclosure, since the current block is a unit of predictionperformance, the current block may be used as the same meaning as thecurrent prediction block, and the neighboring block may be used as thesame meaning as a neighboring prediction block.

The image encoding apparatus may search for merge candidate blocks usedto derive the motion information of the current block to perform themerge mode. For example, up to five merge candidate blocks may be used,without being limited thereto. The maximum number of merge candidateblocks may be transmitted in a slice header or a tile group header,without being limited thereto. After finding the merge candidate blocks,the image encoding apparatus may generate a merge candidate list andselect a merge candidate block with smallest RD cost as a final mergecandidate block.

The merge candidate list may use, for example, five merge candidateblocks. For example, four spatial merge candidates and one temporalmerge candidate may be used.

Overview of Affine Mode

Hereinafter, an affine mode which is an example of an inter predictionmode will be described in detail. In a conventional videoencoding/decoding system, only one motion vector is used to expressmotion information of a current block (translation motion model).However, in a conventional method, optimal motion information is onlyexpressed in units of blocks, but optimal motion information cannot beexpressed in units of pixels. In order to solve this problem, an affinemotion mode defining motion information of a block in units of pixelshas been proposed. According to the affine mode, a motion vector foreach pixel and/or subblock unit of a block may be determined using twoto four motion vectors associated with a current block.

Compared to the existing motion information expressed using translation(or displacement) of a pixel value, in the affine mode, motioninformation for each pixel may be expressed using at least one oftranslation, scaling, rotation or shear.

FIG. 8 is a view illustrating motion expressible in an affine mode.

Among motions shown in FIG. 8 , an affine mode in which motioninformation for each pixel is expressed using displacement, scaling orrotation may be similarity or simplified affine mode. The affine mode inthe following description may mean a similarity or simplified affinemode.

Motion information in the affine mode may be expressed using two or morecontrol point motion vectors (CPMVs). A motion vector of a specificpixel position of a current block may be derived using a CPMV. In thiscase, a set of motion vectors for each pixel and/or subblock of acurrent block may be defined as an affine motion vector field (affineMVF).

FIG. 9 is a view illustrating a parameter model of an affine mode.

When an affine mode applies to a current block, an affine MVF may bederived using one of a 4-parameter model and a 6-parameter model. Inthis case, the 4-parameter model may mean a model type in which twoCPMVs are used and the 6-parameter model may mean a model type in whichthree CPMVs are used. FIGS. 9(a) and 9(b) show CPMVs used in the4-parameter model and the 6-parameter model, respectively.

When the position of the current block is (x, y), a motion vectoraccording to the pixel position may be derived according to Equation 1or 2 below. For example, the motion vector according to the 4-parametermodel may be derived according to Equation 1 and the motion vectoraccording to the 6-parameter model may be derived according to Equation2.

$\begin{matrix}\{ \begin{matrix}{{mv}_{x} = {{\frac{{mv}_{1x} - {mv}_{0x}}{W}x} + {\frac{{mv}_{1y} - {mv}_{0y}}{W}y} + {mv}_{0x}}} \\{{mv}_{y} = {{\frac{{mv}_{1y} - {mv}_{0y}}{W}x} + {\frac{{mv}_{1x} - {mv}_{0x}}{W}y} + {mv}_{0y}}}\end{matrix}  &  \{ {{Equation}1}  \rbrack\end{matrix}$ $\begin{matrix}\{ \begin{matrix}{{mv}_{x} = {{\frac{{mv}_{1x} - {mv}_{0x}}{W}x} + {\frac{{mv}_{2x} - {mv}_{0x}}{H}y} + {mv}_{0x}}} \\{{mv}_{y} = {{\frac{{mv}_{1y} - {mv}_{0y}}{W}x} + {\frac{{mv}_{2y} - {mv}_{0y}}{H}y} + {mv}_{0y}}}\end{matrix}  &  \{ {{Equation}2}  \rbrack\end{matrix}$

In Equations 1 and 2, mv0={mv_0x, mv_0y} may be a CPMV at the top leftcorner position of the current block, mv1={mv_1x, mv_1y} may be a CPMVat the top right position of the current block, and mv2={mv_2x, mv_2y}may be a CPMV at the bottom left position of the current block. In thiscase, W and H respectively correspond to the width and height of thecurrent block, and mv={mv_x, mv_y} may mean a motion vector of a pixelposition {x, y}.

In an encoding/decoding process, an affine MVF may be determined inunits of pixels and/or predefined subblocks. When the affine MVF isdetermined in units of pixels, a motion vector may be derived based oneach pixel value. Meanwhile, when the affine MVF is determined in unitsof subblocks, a motion vector of a corresponding block may be derivedbased on a center pixel value of a subblock. The center pixel value maymean a virtual pixel present in the center of a subblock or a bottomright pixel among four pixels present in the center. In addition, thecenter pixel value may be a specific pixel in a subblock and may be apixel representing the subblock. In the present disclosure, the casewhere the affine MVF is determined in units of 4×4 subblocks will bedescribed. However, this is only for convenience of description and thesize of the subblock may be variously changed.

That is, when affine prediction is available, a motion model applicableto a current block may include three models, that is, a translationalmotion model, a 4-parameter affine motion model and 6-parameter affinemotion model. Here, the translational motion model may represent a modelused by an existing block unit motion vector, the 4-parameter affinemotion model may represent a model used by two CPMVs, and the6-parameter affine motion model may represent a model used by threeCPMVs. The affine mode may be divided into detailed modes according to amethod of encoding/decoding motion information. For example, the affinemode may be subdivided into an affine MVP mode and an affine merge mode.

When an affine merge mode applies for a current block, a CPMV may bederived from neighboring blocks of the current block encoded/decoded inthe affine mode. When at least one of the neighboring blocks of thecurrent block is encoded/decoded in the affine mode, the affine mergemode may apply for the current block. That is, when the affine mergemode applies for the current block, CPMVs of the current block may bederived using CPMVs of the neighboring blocks. For example, the CPMVs ofthe neighboring blocks may be determined to be the CPMVs of the currentblock or the CPMV of the current block may be derived based on the CPMVsof the neighboring blocks. When the CPMV of the current block is derivedbased on the CPMVs of the neighboring blocks, at least one of codingparameters of the current block or the neighboring blocks may be used.For example, CPMVs of the neighboring blocks may be modified based onthe size of the neighboring blocks and the size of the current block andused as the CPMVs of the current block.

Meanwhile, affine merge in which an MV is derived in units of subblocksmay be referred to as a subblock merge mode, which may be specified bymerge_subblock_flag having a first value (e.g., 1). In this case, anaffine merging candidate list described below may be referred to as asubblock merging candidate list. In this case, a candidate derived asSbTMVP described below may be further included in the subblock mergingcandidate list. In this case, the candidate derived as sbTMVP may beused as a candidate of index #0 of the subblock merging candidate list.In other words, the candidate derived as sbTMVP may be located in frontof an inherited affine candidates and constructed affine candidatesdescribed below in the subblock merging candidate list.

For example, an affine mode flag specifying whether an affine mode isapplicable to a current block may be defined, which may be signaled atleast one of higher levels of the current block, such as a sequence, apicture, a slice, a tile, a tile group, a brick, etc. For example, theaffine mode flag may be named sps_affine_enabled_flag.

When the affine merge mode applies, an affine merge candidate list maybe configured to derive the CPMV of the current block. In this case, theaffine merge candidate list may include at least one of an inheritedaffine merge candidate, a constructed affine merge candidate or a zeromerge candidate. The inherited affine merge candidate may mean acandidate derived using the CPMVs of the neighboring blocks when theneighboring blocks of the current block are encoded/decoded in theaffine mode. The constructed affine merge candidate may mean a candidatehaving each CPMV derived based on motion vectors of neighboring blocksof each control point (CP). Meanwhile, the zero merge candidate may meana candidate composed of CPMVs having a size of 0. In the followingdescription, the CP may mean a specific position of a block used toderive a CPMV. For example, the CP may be each vertex position of ablock.

FIG. 10 is a view illustrating a method of generating an affine mergecandidate list.

Referring to the flowchart of FIG. 10 , affine merge candidates may beadded to the affine merge candidate list in order of an inherited affinemerge candidate (S1210), a constructed affine merge candidate (S1220)and a zero merge candidate (S1230). The zero merge candidate may beadded when the number of candidates included in the candidate list doesnot satisfy a maximum number of candidates even though all the inheritedaffine merge candidates and the constructed affine merge candidates areadded to the affine merge candidate list. In this case, the zero mergecandidate may be added until the number of candidates of the affinemerge candidate list satisfies the maximum number of candidates.

FIG. 11 is a view illustrating a control point motion vector (CPMV)derived from a neighboring block.

For example, a maximum of two inherited affine merge candidates may bederived, each of which may be derived based on at least one of leftneighboring blocks and top neighboring blocks.

FIG. 12 is a view illustrating neighboring blocks for deriving aninherited affine merge candidate.

An inherited affine merge candidate derived based on a left neighboringblock is derived based on at least one of neighboring blocks A0 or A1 ofFIG. 12 , and an inherited affine merge candidate derived based on a topneighboring block may be derived based on at least one of neighboringblocks B0, B1 or B2 of FIG. 12 . In this case, the scan order of theneighboring blocks may be A0 to A1 and B0, B1 and B2, but is not limitedthereto. For each of the left and top, an inherited affine mergecandidates may be derived based on an available first neighboring blockin the scan order. In this case, redundancy check may not be performedbetween candidates derived from the left neighboring block and the topneighboring block.

For example, as shown in FIG. 11 , when a left neighboring block A isencoded/decoded in the affine mode, at least one of motion vectors v2,v3 and v4 corresponding to the CP of the neighboring block A may bederived. When the neighboring block A is encoded/decoded through a4-parameter affine model, the inherited affine merge candidate may bederived using v2 and v3. In contrast, When the neighboring block A isencoded/decoded through a 6-parameter affine model, the inherited affinemerge candidate may be derived using v2, v3 and v4.

FIG. 13 is a view illustrating neighboring blocks for deriving aconstructed affine merge candidate.

The constructed affine candidate may mean a candidate having a CPMVderived using a combination of general motion information of neighboringblocks. Motion information for each CP may be derived using spatialneighboring blocks or temporal neighboring blocks of the current block.In the following description, CPMVk may mean a motion vectorrepresenting a k-th CP. For example, referring to FIG. 13 , CPMV1 may bedetermined to be an available first motion vector of motion vectors ofB2, B3 and A2, and, in this case, the scan order may be B2, B3 and A2.CPMV2 may be determined to be an available first motion vector of motionvectors of B1 and B0, and, in this case, the scan order may be B1 andB0. CPMV3 may be determined to be one of motion vectors of A1 and A0,and, in this case, the scan order may be A1 and A0. When TMVP isapplicable to the current block, CPMV4 may be determined as a motionvector of T which is a temporal neighboring block.

After four motion vectors for each CP are derived, a constructed affinemerge candidate may be derived based on this. The constructed affinemerge candidate may be configured by including at least two motionvectors selected from among the derived four motion vectors for each CP.For example, the constructed affine merge candidate may be composed ofat least one of {CPMV1, CPMV2, CPMV3}, {CPMV1, CPMV2, CPMV4}, {CPMV1,CPMV3, CPMV4}, {CPMV2, CPMV3, CPMV4}, {CPMV1, CPMV2} or {CPMV1, CPMV3}in this order. A constructed affine candidate composed of three motionvectors may be a candidate for a 6-parameter affine model. In contrast,a constructed affine candidate composed of two motion vectors may be acandidate for a 4-parameter affine model. In order to avoid the scalingprocess of the motion vector, when the reference picture indices of CPsare different from each other, a combination of related CPMVs may beignored without being used to derive the constructed affine candidate.

When an affine MVP mode applies to a current block, an encoding/decodingapparatus may derive two or more CPMV predictors and CPMVs for thecurrent block and derive CPMV differences based on them. In this case,the CPMV differences may be signaled from the encoding apparatus to thedecoding apparatus. The image decoding apparatus may derive a CPMVpredictor for the current block, reconstruct the signaled CPMVdifference, and then derive a CPMV of the current block based on theCPMV predictor and the CPMV difference.

Meanwhile, when the affine merge mode or a subblock-based TMVP does notapply for the current block (for example, the value of affine merge flagor merge_subblock_flag is 0), an affine MVP mode may apply for thecurrent block. Alternatively, when the value of inter_affine_flag is 1,the affine MVP mode may apply for the current block. Meanwhile, theaffine MVP mode may be expressed as an affine CP MVP mode. An affine mvpcandidate list described below may be referred to as a control pointmotion vectors predictor candidate list.

When the affine MVP mode applies for the current block, an affine MVPcandidate list may be configured to derive a CPMV for the current block.In this case, the affine MVP candidate list may include at least one ofan inherited affine MVP candidate, a constructed affine MVP candidate, atranslation motion affine MVP candidate or a zero MVP candidate. Forexample, the affine MVP candidate list may include a maximum of n (e.g.,n=2) candidates.

In this case, the inherited affine MVP candidate may mean a candidatederived based on the CPMVs of the neighboring blocks, when theneighboring blocks of the current block are encoded/decoded in an affinemode. The constructed affine MVP candidate may mean a candidate derivedby generating a CPMV combination based on a motion vector of a CPneighboring block. The zero MVP candidate may mean a candidate composedof CPMVs having a value of 0. The derivation method and characteristicsof the inherited affine MVP candidate and the constructed affine MVPcandidate are the same as the above-described inherited affine candidateand the constructed affine candidate and thus a description thereof willbe omitted.

When the maximum number of candidates of the affine MVP candidate listis 2, the constructed affine MVP candidate, the translation motionaffine MVP candidate and the zero MVP candidate may be added when thecurrent number of candidates is less than 2. In particular, thetranslation motion affine MVP candidate may be derived in the followingorder.

For example, when the number of candidates included in the affine MVPcandidate list is less than 2 and CPMV0 of the constructed affine MVPcandidate is valid, CPMV0 may be used as an affine MVP candidate. Thatis, affine MVP candidates having all motion vectors of CP0, CP1, CP2being CPMV0 may be added to the affine MVP candidate list.

Next, when the number of candidates of the affine MVP candidate list isless than 2 and CPMV1 of the constructed affine MVP candidate is valid,CPMV1 may be used as an affine MVP candidate. That is, affine MVPcandidates having all motion vectors of CP0, CP1, CP2 being CPMV1 may beadded to the affine MVP candidate list.

Next, when the number of candidates of the affine MVP candidate list isless than 2 and CPMV2 of the constructed affine MVP candidate is valid,CPMV2 may be used as an affine MVP candidate. That is, affine MVPcandidates having all motion vectors of CP0, CP1, CP2 being CPMV2 may beadded to the affine MVP candidate list.

Despite the above-described conditions, when the number of candidates ofthe affine MVP candidate list is less than 2, a temporal motion vectorpredictor (TMVP) of the current block may be added to the affine MVPcandidate list. Despite the above, when the number of candidates of theaffine MVP candidate list is less than 2, a zero MVP candidate may beadded to the affine MVP candidate list.

FIG. 14 is a view illustrating a method of generating an affine MVPcandidate list.

Referring to the flowchart of FIG. 14 , candidates may be added to theaffine MVP candidate list in order of an inherited affine MVP candidate(S1610), a constructed affine MVP candidate (S1620), a translationmotion affine MVP candidate (S1630) and a zero MVP candidate (S1640). Asdescribed above, steps S1620 to S1640 may be performed depending onwhether the number of candidates included in the affine MVP candidatelist is less than 2 in each step.

The scan order of the inherited affine MVP candidates may be equal tothe scan order of the inherited affine merge candidates. However, in thecase of the inherited affine MVP candidate, only neighboring blocksreferencing the same reference picture as the reference picture of thecurrent block may be considered. When the inherited affine MVP candidateis added to an affine MVP candidate list, redundancy check may not beperformed.

In order to derive the constructed affine MVP candidate, only spatialneighboring blocks shown in FIG. 13 may be considered. In addition, thescan order of the constructed affine MVP candidates may be equal to thescan order of the constructed affine merge candidates. In addition, inorder to derive the constructed affine MVP candidate, a referencepicture index of a neighboring block may be checked, and, in the scanorder, a first neighboring block inter-coded and referencing the samereference picture as the reference picture of the current block may beused.

Overview of Subblock-Based Temporal Motion Vector Prediction (SbTMVP)Mode

Hereinafter, a subblock-based TMVP mode which is an example of an interprediction mode will be described in detail. According to thesubblock-based TMVP mode, a motion vector field (MVF) for a currentblock may be derived and a motion vector may be derived in units ofsubblocks.

Unlike a conventional TMVP mode performed in units of coding units, fora coding unit to which subblock-based TMVP mode applies, a motion vectormay be encoded/decoded in units of sub-coding units. In addition,according to the conventional TMVP mode, a temporal motion vector may bederived from a collocated block in a collocated picture, but, in thesubblock-based TMVP mode, a motion vector field may be derived from areference block in the collocated picture specified by a motion vectorderived from a neighboring block of the current block. Hereinafter, themotion vector derived from the neighboring block may be referred to as amotion shift or representative motion vector of the current block.

FIG. 15 is a view illustrating neighboring blocks of a subblock basedTMVP mode.

When a subblock-based TMVP mode applies to a current block, aneighboring block for determining a motion shift may be determined. Forexample, scan for the neighboring block for determining the motion shiftmay be performed in order of blocks of A1, B1, B0 and A0 of FIG. 15 . Asanother example, the neighboring block for determining the motion shiftmay be limited to a specific neighboring block of the current block. Forexample, the neighboring block for determining the motion shift mayalways be determined to be a block A1. When a neighboring block has amotion vector referencing a col picture, the corresponding motion vectormay be determined to be a motion shift. The motion vector determined tobe the motion shift may be referred to as a temporal motion vector.Meanwhile, when the above-described motion vector cannot be derived fromneighboring blocks, the motion shift may be set to (0, 0).

FIG. 16 is a view illustrating a method of deriving a motion vectorfield according to a subblock-based TMVP mode.

Next, a reference block on the collocated picture specified by a motionshift may be determined. For example, subblock based motion information(motion vector or reference picture index) may be obtained from a colpicture by adding a motion shift to the coordinates of the currentblock. In the example shown in FIG. 16 , it is assumed that the motionshift is a motion vector of A1 block. By applying the motion shift tothe current block, a subblock in a col picture (col subblock)corresponding to each subblock configuring the current block may bespecified. Thereafter, using motion information of the correspondingsubblock in the col picture (col subblock), motion information of eachsubblock of the current block may be derived. For example, the motioninformation of the corresponding subblock may be obtained from thecenter position of the corresponding subblock. In this case, the centerposition may be a position of a bottom-right sample among four sampleslocated at the center of the corresponding subblock. When the motioninformation of a specific subblock of the col block corresponding to thecurrent block is not available, the motion information of a centersubblock of the col block may be determined to be motion information ofthe corresponding subblock. When the motion vector of the correspondingsubblock is derived, it may be switched to a reference picture index anda motion vector of a current subblock, similarly to the above-describedTMVP process. That is, when a subblock based motion vector is derived,scaling of the motion vector may be performed in consideration of POC ofthe reference picture of the reference block.

As described above, the subblock-based TMVP candidate for the currentblock may be derived using the motion vector field or motion informationof the current block derived based on the subblock.

Hereinafter, a merge candidate list configured in units of subblocks isdefined as a subblock unit merge candidate list. The above-describedaffine merge candidate and subblock-based TMVP candidate may be mergedto configure a subblock unit merge candidate list.

Meanwhile, a subblock-based TMVP mode flag specifying whether asubblock-based TMVP mode is applicable to a current block may bedefined, which may be signaled at least one level among higher levels ofthe current block such as a sequence, a picture, a slice, a tile, a tilegroup, a brick, etc. For example, the subblock-based TMVP mode flag maybe named sps_sbtmvp_enabled_flag. When the subblock-based TMVP mode isapplicable to the current block, the subblock-based TMVP candidate maybe first added to the subblock unit merge candidate list and then theaffine merge candidate may be added to the subblock unit merge candidatelist. Meanwhile, a maximum number of candidates which may be included inthe subblock unit merge candidate list may be signaled. For example, themaximum number of candidates which may be included in the subblock unitmerge candidate list may be 5.

The size of a subblock used to derive the subblock unit merge candidatelist may be signaled or preset to M×N. For example, M×N may be 8×8.Accordingly, only when the size of the current block is 8×8 or greater,an affine mode or a subblock-based TMVP mode is applicable to thecurrent block.

Hereinafter, an embodiment of a prediction performing method of thepresent disclosure will be described. The following predictionperforming method may be performed in step S410 of FIG. 4 or step S630of FIG. 6 .

A predicted block for a current block may be generated based on motioninformation derived according to a prediction mode. The predicted block(prediction block) may include prediction samples (prediction samplearray) of the current block. When the motion vector of the current blockspecifies a fractional sample unit, an interpolation procedure may beperformed and, through this, prediction samples of the current block maybe derived based on reference samples in units of fractional sampleswithin a reference picture. When affine inter prediction applies to thecurrent block, prediction samples may be generated based on asample/subblock unit MV. When bi-prediction applies, prediction samplesderived through a weighted sum or weighted average (according to phase)of prediction samples derived based on L0 prediction (that is,prediction using MVL0 and a reference picture within a reference picturelist L0) and prediction samples derived based on L1 prediction (that is,prediction using MLV1 and a reference picture within a reference picturelist L1) may be used as the prediction samples of the current block.When applying bi-prediction and a reference picture used for L0prediction and the reference picture used for L1 prediction are locatedin different temporal directions with respect to the current picture(that is, if it corresponds to bi-prediction and bi-directionalprediction), this may be called true bi-prediction.

In an image decoding apparatus, reconstructed samples and areconstructed picture may be generated based on the derived predictionsamples and then an in-loop filtering procedure may be performed. Inaddition, in an image encoding apparatus, residual samples may bederived based on the derived prediction samples and encoding of imageinformation including prediction information and residual informationmay be performed.

Bi-Prediction with CU-Level Weight, BCW

When bi-prediction applies to a current block as described above,prediction samples may be derived based on a weighted average.Conventionally, the bi-prediction signal (that is, bi-predictionsamples) was able to be derived through a simple average of an L0prediction signal (L0 prediction samples) and an L1 prediction signal(L1 prediction samples). That is, bi-prediction samples was derivedthrough an average of the L0 prediction samples based on an L0 referencepicture and MVL0 and L1 prediction samples based on an L1 referencepicture and MVL1. However, according to the present disclosure, whenapplying bi-prediction, a bi-prediction signal (bi-prediction samples)may be derived through a weighted average of the L0 prediction signaland the L1 prediction signal as follows.

P _(bi-pred)=((8−w)P ₀ +w*+P ₁₊4)>>3

In Equation 3 above, P_(bi-pred) denotes a bi-prediction signal(bi-prediction block) derived by a weighted average and P₀ and P₁respectively denote L0 prediction samples (L0 prediction block) and L1prediction samples (L1 prediction block). In addition, (8−w) and wdenote weights applying to P₀ and P₁, respectively.

In generating the bi-prediction signal by the weighted average, fiveweights may be allowed. For example, the weight w may be selected from{−2, 3, 4, 5, 10}. For each bi-predicted CU, the weight w may bedetermined by one of two methods. As the first method of the twomethods, when a current CU is not a merge mode (non-merge CU), a weightindex may be signaled along with a motion vector difference. Forexample, a bitstream may include information on the weight index afterinformation on the motion vector difference. As the second method of thetwo methods, when the current CU is a merge mode (merge CU), the weightindex may be derived from neighboring blocks based on a merge candidateindex (merge index).

Generation of the bi-prediction signal by the weighted average may belimited to apply to only a CU having a size including 256 or moresamples (luma component samples). That is, bi-prediction by the weightedaverage may be performed only with respect to a CU in which a product ofthe width and height of the current block is 256 or more. In addition,the weight w may be used as one of five weights as described above andone of different numbers of weights may be used. For example, accordingto the characteristics of the current image, five weights may be usedfor a low-delay picture and three weights may be used for anon-low-delay picture. In this case, the three weights may be {3, 4, 5}.

The image encoding apparatus may determine a weight index withoutsignificantly increasing complexity, by applying a fast searchalgorithm. In this case, the fast search algorithm may be summarized asfollows. Hereinafter, an unequal weight may mean that weights applyingto P₀ and P₁ are not equal. In addition, an equal weight may mean thatweights applying to P₀ and P₁ may be equal.

-   -   In the case where an AMVR mode in which resolution of a motion        vector is adaptively changed is applied together, when a current        picture is a low-delay picture, only the unequal weight may be        conditionally checked for each of 1-pel motion vector resolution        and 4-pel motion vector resolution.    -   In the case where an affine mode is applied together and the        affine mode is selected as an optimal mode of the current block,        the image encoding apparatus may perform affine motion        estimation (ME) for each unequal weight.    -   When two reference pictures used for bi-prediction are equal,        only an unequal weight may be conditionally checked.    -   The unequal weight may not be checked when a predetermined        condition is satisfied. The predetermined picture may be based        on a POC distance between a current picture and a reference        picture, a quantization parameter (QP), a temporal level, etc.

A weight index of BCW may be encoded using one context coded bin and oneor more subsequent bypass coded bins. The first context coded binspecifies whether an equal weight is used. When an unequal weight isused, additional bins may be bypass-encoded and signaled. The additionalbins may be signaled to specify which weight is used.

Weighted prediction (WP) is a tool for efficiently encoding an imageincluding fading. According to weighted prediction, weighting parameters(weight and offset) may be signaled for each reference picture includedin each of reference picture lists L0 and L1. Then, when motioncompensation is performed, weight(s) and offset(s) may apply tocorresponding reference picture(s). Weighted prediction and BCW may beused for different types of images. In order to avoid interactionbetween weighted prediction and BCW, a BCW weight index may not besignaled for a CU using weighted prediction. In this case, the weightmay be inferred to be 4. That is, an equal weight may be applied.

In the case of a CU to which a merge mode applies, a weight index may beinferred from neighboring blocks based on a merge candidate index. Thismay apply to both a general merge mode and an inherited affine mergemode.

In the case of a constructed affine merge mode, affine motioninformation may be configured based on motion information of a maximumof three blocks. A BCW weight index for a CU using a constructed affinemerge mode may be set to a BCW weight index of a first CP in acombination. That is, BCW may not apply to a CU encoded in a CIIP mode.For example, a BCW weight index of a CU encoded in a CIIP mode may beset to a value specifying an equal weight.

Bi-Directional Optical Flow (BDOF)

According to the present disclosure, BDOF may be used to refine abi-prediction signal. BDOF is to generate prediction samples bycalculating refined motion information when bi-prediction applies to acurrent block (e.g., CU). Accordingly, a process of calculating refinedmotion information by applying BDOF may be included in theabove-described motion information derivation step.

For example, BDOF may apply at a 4×4 sub-block level. That is, BDOF maybe performed within the current block in units of 4×4 sub-blocks.

BODF may, for example, apply to a CU satisfying at least one or all ofthe following conditions.

-   -   the CU is encoded in a true bi-prediction mode, that is, one of        two reference pictures precedes a current picture in display        order and the other follows the current picture in display order    -   the CU is not in an affine mode or an ATMVP merge mode    -   the CU has more than 64 luma samples    -   the height and width of the CU are 8 luma samples or more    -   a BCW weight index specifies an equal weight, that is, applying        an equal weight to an L0 prediction sample and an L1 prediction        sample

weighted prediction (WP) does not apply to a current CU

a CIIP mode is used for the current CU

In addition, BDOF may apply only to a luma component. However, thepresent disclosure is not limited thereto and BDOF may apply to a chromacomponent or both a luma component and a chroma component.

A BDOF mode is based on the concept of optical flow. That is, it isassumed that motion of an object is smooth. When applying BDOF, for each4×4 sub-block, a motion refinement (v_(x), v_(y)) may be calculated. Themotion refinement may be calculated by minimizing a difference betweenan L0 prediction sample and an L1 prediction sample. The motionrefinement may be used to adjust bi-predicted sample values within a 4×4sub-block.

Hereinafter, a process of performing BDOF will be described in greaterdetail.

First, horizontal gradients ∂I/∂x(i,j) and vertical gradients∂I^((k))/∂y(i,j) of two prediction signals may be calculated. In thiscase, k may be 0 or 1. The gradients may be calculated by directlycalculating a difference between two adjacent samples. For example, thegradients may be calculated as follows.

$\begin{matrix} {{\frac{\partial I^{(k)}}{\partial x}( {i,j} )} = ( {{( {{I^{(k)}( {i + {1,j}} )} \gg {{shift}1}} ) - {\lbrack ( I  \rbrack^{(k)}( {i - {1,j}} )}} \gg {{shift}1}} )} ) & \lbrack {{Equation}4} \rbrack\end{matrix}$${\frac{\partial I^{(k)}}{\partial y}( {i,j} )} = ( {( {{I^{(k)}( {{i,j} + 1} )} \gg {{shift}1}} ) - ( {{I^{(k)}( {{i,j} - 1} )} \gg {{shift}1}} )} )$

In Equation 4 above, I^((k))(i, j) denotes a sample value of coordinates(i, j) of a prediction signal in a list k (k=0, 1). For example, I⁽⁰⁾(i,j) may denote a sample value at a position (i, j) in an L0 predictionblock, and I⁽¹⁾(i, j) may denote a sample value at a position (i, j) inan L1 prediction block. In Equation 4 above, the first shift shift1 maybe determined based on a bit depth of a luma component. For example,when the bit depth of the luma component is bitDepth, shift1 may bedetermined to be max(6, bitDepth−6).

As described above, after calculating the gradients, auto-correlationand cross-correlation S₁, S₂, S₃, S₅ and S₆ between the gradients may becalculated as follows.

$\begin{matrix}{{S_{1} = {\sum_{{({i,j})} \in \Omega}{{Abs}( {\psi_{x}( {i,j} )} )}}},{S_{3} = {\sum_{{({i,j})} \in \Omega}{{\theta( {i,j} )} \cdot {{Sign}( {\psi_{x}( {i,j} )} )}}}}} & \lbrack {{Equation}5} \rbrack\end{matrix}$ S₂ = ∑_((i, j) ∈ Ω)ψ_(x)(i, j) ⋅ Sign(ψ_(y)(i, j))S₅ = ∑_((i, j) ∈ Ω)Abs(ψ_(y)(i, j))S₆ = ∑_((i, j) ∈ Ω)θ(i, j) ⋅ ψ_(y)(i, j)where${\psi_{x}( {i,j} )} = {( {{\frac{\partial I^{(1)}}{\partial x}( {i,j} )} + {\frac{\partial I^{(0)}}{\partial x}( {i,j} )}} ) \gg n_{a}}$${\psi_{y}( {i,j} )} = {( {{\frac{\partial I^{(1)}}{\partial y}( {i,j} )} + {\frac{\partial I^{(0)}}{\partial y}( {i,j} )}} ) \gg n_{a}}$θ(i, j) = (I⁽¹⁾(i, j) ≫ n_(b)) − (I⁽⁰⁾(i, j) ≫ n_(b))

where Ω is a 6×6 window around the 4×4 sub-block.

In Equation 5 above, n_(a) and n_(b) may be set to min(1, bitDepth−11)and min(4, bitDepth−8), respectively.

The motion refinement (v_(x), v_(y)) may be derived as follows using theabove-described auto-correlation and cross-correlation between thegradients.

v _(x) =S ₁>0?clip3(−th′ _(BIO) ,th′ _(BIO′)−((S ₃·2^(n) ^(b) ^(-n) ^(a))>>└log₂ S ₁┘)):0

v _(y) =S _(s)>0?clip3(−th′ _(BIO) ,th′ _(BIO′)−((S ₆·2^(n) ^(b) ^(-n)^(a) −((v _(x) S _(2,m))<<n _(s) ₂ +v _(x) S _(2,s))/2)>>└log₂ S₅┘)):0  [Equation 6]

where S_(2,m)=S₂>>n_(s) ₂ , S_(2, s)=S_2&(2{circumflex over( )}(n_(S_2))−1), th′_(BIO)=2^(13-BD). and └⋅┘ is the floor function.

In Equation 6 above, n_(S2) may be 12. Based on the derived motionrefinement and gradients, the following adjustment may be performed withrespect to each sample in the 4×4 sub-block.

$\begin{matrix}{{b( {x,y} )} = {{rnd}( {( {{v_{x}( {\frac{\partial{I^{(1)}( {x,y} )}}{\partial x} - \frac{\partial{I^{(0)}( {x,y} )}}{\partial x}} )} + \text{ }{v_{y}( {\frac{\partial{I^{(1)}( {x,y} )}}{\partial y} - \frac{\partial{I^{(0)}( {x,y} )}}{\partial y}} )} + 1} )/2} )}} & \lbrack {{Equation}7} \rbrack\end{matrix}$

Finally, prediction samples pred_(BDOF) of a CU, to which BDOF applies,may be calculated by adjusting the bi-prediction samples of the CU asfollows.

Pre_(BDOF)(x,y)=(I ⁽⁰⁾(x,y)+I ⁽¹⁾(x,y)+b(x,y)+o_(offset))>>shift  [Equation 8]

In above Equations, n_(a), n_(b) and n_(S2) may be 3, 6 and 12,respectively. These values may be selected such that a multiplier doesnot exceed 15 bits in the BDOF process and bit-widths of intermediateparameters are maintained within 32 bits.

In order to derive a gradient value, prediction samples I^((k))(i, j) ina list k (k=0, 1) existing outside a current CU may be generated. FIG.17 is a view illustrating a CU extended to perform BDOF.

As shown in FIG. 17 , in order to perform BDOF, rows/columns extendingaround the boundary of a CU may be used. In order to controlcomputational complexity for generating prediction samples outside theboundary, prediction samples in an extended region (white region in FIG.17 ) may be generated using a bilinear filter, and prediction samples ina CU (gray region in FIG. 17 ) may be generated using a normal 8-tapmotion compensation interpolation filter. The sample values at theextended positions may be used only for gradient calculation. Whensample values and/or gradient values located outside the CU boundary arerequired to perform the remaining steps of the BDOF process, nearestneighboring sample values and/or gradient values may be padded(repeated) and used.

When the width and/or height of the CU are greater than 16 luma samples,the corresponding CU may be split into sub-blocks having a width and/orheight of 16 luma samples. The boundary of the sub-blocks may be treatedin the same manner as the above-described CU boundary in the BDOFprocess. A maximum unit size in which the BDOF process is performed maybe limited to 16×16.

For each subblock, whether BDOF is performed may be determined. That is,the BDOF process for each subblock may be skipped. For example, when anSAD value between an initial L0 prediction sample and an initial L1prediction sample is less than a predetermined threshold, the BDOFprocess may not apply to the corresponding subblock. In this case, whenthe width and height of the corresponding subblock are W and H, thepredetermined threshold may be set to (8*W*(H>>1). In consideration ofcomplexity of additional SAD calculation, the SAD between the initial L0prediction sample and the initial L1 prediction sample calculated in theDMVR process may be reused.

When BCW is available for a current block, for example, when a BCWweight index specifies an unequal weight, BDOF may not apply. Similarly,when WP is available for the current block, for example, whenluma_weight_lx_flag for at least one of two reference pictures is 1,BDOF may not apply. In this case, luma_weight_lx_flag may be informationspecifying whether weighting factors of WP for a luma component of lxprediction (x being 0 or 1) is present in a bitstream or informationspecifying whether WP applies to a luma component of lx prediction. Whenthe CU is encoded in a symmetric MVD (SMVD) mode or a CIIP mode, BDOFmay not apply.

Prediction Refinement with Optical Flow (PROF)

Hereinafter, a method of refining a sub-block based affine motioncompensation-predicted block by applying optical flow will be described.Prediction samples generated by performing sub-block based affine motioncompensation may be refined based on a difference derived by an opticalflow equation. Refinement of such prediction samples may be calledprediction refinement with optical flow (PROF) in the presentdisclosure. By PROF, inter prediction of pixel level granularity may beachieved without increasing bandwidth of memory access.

Parameters of an affine motion model may be used to derive a motionvector of each pixel in a CU. However, since pixel based affine motioncompensation prediction causes high complexity and an increase inbandwidth of memory access, sub-block based affine motion compensationprediction may be performed. When sub-block based affine motioncompensation prediction is performed, the CU may be split into 4×4sub-blocks and a motion vector may be determined for each sub-block. Inthis case, the motion vector of each sub-block may be derived from CPMVsof the CU. Sub-block based affine motion compensation has a trad-offrelationship between encoding efficiency and complexity and bandwidth ofmemory access. Since a motion vector is derived in units of sub-blocks,complexity and bandwidth of memory access are reduced but predictionaccuracy is lowered.

Accordingly, motion compensation of refined granularity may be achievedthrough refinement by applying optical flow to sub-block based affinemotion compensation prediction.

As described above, luma prediction samples may be refined by adding adifference derived by an optical flow equation after performingsub-block based affine motion compensation. More specifically, PROF maybe performed in the following four steps.

Step 1) A predicted sub-block I(i, j) is generated by performingsub-block based affine motion compensation.

Step 2) Spatial gradients g_(x)(i, j) and g_(y)(i, j) of the predictedsub-block is calculated at each sample position. In this case, a 3-tapfilter may be used, and filter coefficient may be [−1, 0, 1]. Forexample, the spatial gradients may be calculated as follows.

g _(x)(i,j)=I(i+1,j)−I(i−1,j)

g _(y)(i,j)=I(i,j+1)−I(i,j−1)  [Equation 9]

To calculate the gradients, predicted sub-blocks may extend by one pixelon each side. In this case, to lower memory bandwidth and complexity,pixels of extended boundaries may be copied from closest integer pixelsin a reference picture. Accordingly, additional interpolation for apadding region may be skipped.

Step 3) Luma prediction refinement (ΔI(i, j)) may be calculated by anoptical flow equation. For example, the following equation may be used.

ΔI(i,j)=g _(x)(i,j)*Δv _(x)(i,j)+g _(y)(i,j)*Δv _(y)(i,j)  [Equation 10]

In the above equation, Δv(i, j) denotes a difference between a pixelmotion vector (pixel MV, v(i, j)) calculated at a sample position (i, j)and a sub-block MV of a sub-block, to which a sample (i, j) belongs.

FIG. 18 is a view illustrating a relationship among Δv(i, j), v(i, j)and a sub-block motion vector.

In the example shown in FIG. 18 , for example, a difference between amotion vector v(i, j) at a top-left sample position of a currentsub-block and a motion vector v_(SB) of the current sub-block may berepresented by a thick dotted arrow, and a vector represented by thethick dotted arrow may correspond to Δv(i, j).

Affine model parameters and pixel positions from the center of thesub-block are not changed. Accordingly, Δv(i, j) may be calculated onlyfor a first sub-block and may be reused for the other sub-blocks in thesame CU. Assuming that a horizontal offset and a vertical offset fromthe pixel position to the center of the sub-block are respectively x andy, Δv(x, y) may be derived as follows.

$\begin{matrix}\{ \begin{matrix}{{\Delta{v_{x}( {x,y} )}} = {{c*x} + {d*y}}} \\{{\Delta{v_{y}( {x,y} )}} = {{e*x} + {f*y}}}\end{matrix}  & \lbrack {{Equation}11} \rbrack\end{matrix}$

For 4-parameter affine model,

$\{ \begin{matrix}{c = {f = \frac{v_{1x} - v_{0x}}{w}}} \\{e = {{- d} = \frac{v_{1y} - v_{0y}}{w}}}\end{matrix} $

For 6-parameter affine model,

$\{ \begin{matrix}{c = \frac{v_{1x} - v_{0x}}{w}} \\{d = \frac{v_{2x} - v_{0x}}{h}} \\{e = \frac{v_{1y} - v_{0y}}{w}} \\{f = \frac{v_{2y} - v_{0y}}{h}}\end{matrix} $

In the above, (v_(0x), v_(0y)), (v_(1x), v_(1y)) and (v_(2x), v_(2y))respectively correspond to a top-left CPMV, a top-right CPMV and abottom-left CPMV, and w and h respectively denote the width and heightof the CU.

Step 4) Finally, a final prediction block I′(i, j) may be generatedbased on the calculated luma prediction refinement ΔI(i, j) and thepredicted sub-block I(i, j). For example, a final prediction block I′may be generated as follows.

I′(i,j)=I(i,j)+ΔI(i,j)  [Equation 12]

FIG. 19 is a view illustrating an example of a process of determiningwhether to apply BDOF according to the present disclosure.

Whether BDOF applies to a current CU may be specified by a flagbdofFlag. bdofFlag of a first value (“true” or “1”) may specify thatBDOF applies to the current CU. bdofFlag of a second value (“False” or“0”) may specify that BDOF does not apply to the current CU. bdofFlagmay be derived, for example, based on various conditions shown in FIG.19 . As shown in FIG. 19 , bdofFlag includes conditions related to sizes(cbWidth, cbHeight) of a block. More specifically, bdofFlag may be setto a first value when both the width cbWidth of the block and the heightcbHeight of the block are equal to or greater than 8 (luma samples) andcbHeight*cbWidth is equal to or greater than 128 (luma samples). In thiscase, cbHeight*cbWidth may specify the number of luma samples includedin the current CU. According to the example shown in FIG. 19 , bdofFlagmay be set to a second value for a CU having a size of 8×8 and thus BDOFdoes not apply.

As described above, by applying BDOF in an inter prediction process torefine a reference sample in a motion compensation process, it ispossible to increase compression performance of an image. BDOF may beperformed when the prediction mode of the current block is a normal mode(regular merge mode or regular AMVP mode). That is, BDOF does not applywhen the prediction mode of the current block is an affine mode, a GPMmode or a CIIP mode.

PROF may be performed on a block encoded in an affine mode, as a methodsimilar to BDOF. As described above, by refining a reference sample ineach 4×4 sub-block through PROF, it is possible to increase compressionperformance of an image.

PROF according to the present disclosure may be performed according tothe prediction direction. The prediction direction may include an L0prediction direction and an L1 prediction direction. When PROF isperformed in the L0 prediction direction, the above-described PROFprocess may apply to an L0 prediction sample, thereby generating arefined L0 prediction sample. When PROF is performed in the L1prediction direction, the above-described PROF process may apply to theL1 prediction sample, thereby generating a refined L1 prediction sample.Accordingly, whether to apply PROF may be derived in both the L0prediction direction and the L1 prediction direction. For example, aflag cbProfFlag specifying whether to apply PROF may includecbProfFlagL0 related to the L0 prediction direction and cbProfFlagL1related to the L1 prediction direction. Whether PROF applies to thecurrent block (CU) may be determined based on cbProfFlagL0 and/orcbProfFlagL1 for each of the L0 prediction direction and the L1prediction direction. In the present disclosure, when cbProfFlagL0and/or cbProfFlagL1 are a first value, it may mean that PROF isperformed in the corresponding prediction direction of the current CU.More specifically, when cbProfFlagL0 is a first value, PROF may beperformed in the L0 prediction direction of the current CU. In addition,when cbProfFlagL1 is a first value, PROF may be performed in the L1prediction direction of the current CU. In the present disclosure,applying PROF to the current CU may mean that cbProfFlagLX (X=0and/or 1) has a first value. In various embodiments of the presentdisclosure, various conditions for deriving cbProfFlagLX may beconditions for the corresponding prediction direction LX.

FIG. 20 is a view illustrating an example of a process of determiningwhether to apply PROF according to the present disclosure.

Whether PROF applies to a current CU may be specified by a flagcbProfFlagLX (X=0 or 1). cbProfFlag of a first value (“True” or “1”) mayspecify that PROF applies to the current CU. cbProfFlag of a secondvalue (“False” or “0) may specify that PROF does not apply to thecurrent CU. cbProfFlag may be derived, for example, based on variousconditions shown in FIG. 20 . As shown in FIG. 20 , cbProfFlag does notinclude conditions related to sizes (cbWidth, cbHeight) of a block.

Since PROF is applicable to a block (affine block) encoded in an affinemode, the size of the block, to which PROF applies, may be constrainedby the block size condition for the affine block. Accordingly, asdescribed below, block size conditions for PROF and BDOF are differentfrom each other.

FIG. 21 is a view illustrating signaling of information specifyingwhether to apply a subblock merge mode according to an example of thepresent disclosure.

Whether a subblock merge mode (affine merge mode) applies to a currentCU may be determined based on information (e.g., merge_subblock_flag ofFIG. 21 ) signaled through a bitstream. merge_subblock_flag of a firstvalue (“True” or “1”) may specify that a subblock merge mode applies tothe current CU. In this case, an index (e.g., merge_subblock_idx of FIG.21 ) specifying one of candidates included in the subblock mergecandidate list may be signaled. When one candidate is present in thesubblock merge candidate list (when MaxNumSubblockMergeCand is 1), theindex information for selecting the candidate is not signaled and may bedetermined to be a fixed value of 0. As shown in FIG. 21 , the signalingcondition of merge_subblock_flag includes conditions related to theblock size. Specifically, when both the width cbWidth and heightcbHeight of the block are equal to or greater than 8,merge_subblock_flag may be signaled. That is, the subblock merge modemay apply to a block having a size of an 8×8 block or more. Accordingly,PROF for an affine merge block may apply to a block having a size of an8×8 block or more.

FIG. 22 is a view illustrating signaling of information specifyingwhether to apply an affine MVP mode according to an embodiment of thepresent disclosure.

Whether an affine MVP mode (inter_affine_mode) applies to a current CUmay be determined based on information (e.g., inter_affine_flag of FIG.22 ) signaled through a bitstream. inter_affine_flag of a first value(“True” or “1”) may specify that the affine MVP mode applies to thecurrent CU. In this case, an index specifying one of candidates includedin an affine MVP candidate list may be signaled. As shown in FIG. 22 ,the signaling conditions of inter_affine_flag include conditions relatedto block sizes. Specifically, when both the width cbWidth and heightcbHeight of the current block are equal to or greater than 16,inter_affine_flag may be signaled. That is, the affine MVP mode mayapply to a block having a size of a 16×16 block or more. Accordingly,PROF for the affine MVP block may apply to a block having a size of a16×16 block or more.

As described with reference to FIGS. 20 to 22 , since PROF does notinclude conditions related to block sizes, a block size to which PROF isapplicable may be constrained according to a block size to which anaffine merge mode and an affine MVP mode are applicable. For example,the affine merge mode is applicable to a block having a size of an 8×8block or more, and, in this case, PROF may apply to an 8×8 block.However, the application condition of BDOF includes a condition in whichcbHeight*cbWidth is equal to or greater than 128 samples, BDOF does notapply to the 8×8 block. Accordingly, the block size to which PROFapplies is different from the block size to which BDOF applies.

The present disclosure provides various embodiments for matchingapplication conditions of PROF and BDOF. Specifically, the presentdisclosure provides various embodiments for matching conditions relatedto block sizes for PROF and BDOF. In addition, the present disclosureprovide various embodiments for matching application conditions of PROFand BDOF in consideration of BCW or WP. In addition, the presentdisclosure provides various embodiments including conditions related toresolution of a current picture and resolution of a reference picture asthe application condition of PROF.

FIG. 23 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

Compared with the example of FIG. 20 , the embodiment of FIG. 23 mayadditionally include a condition related to block sizes as theapplication condition of PROF. More specifically, as shown in theunderlined portion of FIG. 23 , when cbHeight*cbWidth is less than 128(luma samples), cbProfFlag may be set to a second value (“False” or“0”).

Accordingly, according to the embodiment of FIG. 23 , it may beconstrained such that PROF does not apply to an 8×8 block to which anaffine merge mode applies. That is, as in the embodiment of FIG. 23 , byadding a condition related to block sizes to the application conditionsof PROF, it is possible to match conditions related to block sizes, towhich PROF and BDOF are applicable.

According to the embodiment of FIG. 23 , conditions related to blocksizes of the affine MVP mode, the affine merge mode, PROF and BDOF maybe changed as shown in the following table.

TABLE 1 affine MVP Affine merge PROF BDOF Examples of w >= 16 && w >= 8&& — w >= 8 && FIGS. 19 to h >= 16 h >= 8 h >= 8 22 && w*h >= 128Example of w >= 16 && w >= 8 && w*h >= 128 w >= 8 && FIG. 23 h >= 16h >= 8 h >= 8 && w*h >= 128

In Table 1 above, w and h may mean the width and height of the currentblock, respectively.

FIG. 24 is a view illustrating signaling of information specifyingwhether to apply a subblock merge mode according to another embodimentof the present disclosure.

In the example of FIG. 21 , a condition related to block sizes amongsignaling conditions of merge_subblock_flag includes a condition inwhich both cbWidth and cbHeight are equal to or greater than 8.According to the embodiment of FIG. 24 , the signaling conditions ofmerge_subblock_flag may additionally include a condition in whichcbWidth*cbHeight is equal to or greater than 128 (luma samples).According to the embodiment of FIG. 24 , the affine merge mode isapplicable to only a block including 128 samples or more as a blockhaving a size of an 8×8 block or more. That is, since the affine mergemode does not apply to the 8×8 block, PROF may not apply to the 8×8block.

According to the embodiment of FIG. 24 , conditions related to blocksizes of the affine MVP mode, the affine merge mode, PROF and BDOF maybe changed as shown in the following table.

TABLE 2 affine MVP Affine merge PROF BDOF Examples of w >= 16 && w >= 8&& — w >= 8 && h >= 8 FIGS. 19 to 22 h >= 16 h >= 8 && w*h >= 128Example of w >= 16 && w >= 8 && — w >= 8 && h >= 8 FIG. 24 h >= 16 h >=8 && w*h >= 128 && w*h >= 128

FIG. 25 is a view illustrating signaling of information specifyingwhether to apply an affine MVP mode according to another embodiment ofthe present disclosure.

In the example of FIG. 22 , a condition related to block sizes amongsignaling conditions of inter_affine_flag includes a condition in whichboth cbWidth and cbHeight are equal to or greater than 16. According tothe embodiment of FIG. 25 , the condition related to block sizes amongsignaling conditions of inter_affine_flag may be changed to a conditionin which both cbWidth and cbHeight are equal to or greater than 16 andcbWidth*cbHeight is equal to or greater than 128 (luma samples).According to the embodiment of FIG. 25 , the affine MVP mode isapplicable to only a block including 128 samples or more as a blockhaving a size of an 8×8 block or more. That is, according to theembodiment of FIG. 25 , the condition related to block sizes for theaffine MVP mode may be matched with the condition related to block sizesfor the BDOF. Therefore, according to the embodiment of FIG. 25 , sincethe affine MVP mode does not apply to the 8×8 block, PROF may not applyto the 8×8 block.

In addition, the embodiment of FIG. 25 may be combined with theembodiment of FIG. 24 . That is, both the block size condition for theaffine MVP mode and the block size condition for the affine merge modemay match the block size condition for BDOF. Therefore, the block sizecondition of PROF applicable to the affine block may match the blocksize condition of BDOF.

According to the embodiment of FIGS. 24 and 25 , conditions related toblock sizes of the affine MVP mode, the affine merge mode, PROF and BDOFmay be changed as shown in the following table.

TABLE 3 affine MVP Affine merge PROF BDOF Examples of w >= 16 && w >= 8&& — w >= 8 && h >= 8 FIGS. 19 to 22 h >= 16 h >= 8 && w*h >= 128Examples of w >= 8 && w >= 8 && — w >= 8 && h >= 8 FIGS. 24 to 25 h >= 8h >= 8 && w*h >= 128 && w*h >= && w*h >= 128 128

FIG. 26 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

In BDOF, the offset of the sample is determined using thecharacteristics of optical flow. Accordingly, when the brightness valuesof the reference pictures are different, that is, when applying BCW orweighted prediction (WP), BDOF is not performed. However, PROF may beperformed without considering whether to apply BCW or WP, in spite ofderiving the offset of the sample using the characteristics of opticalflow.

According to the embodiment of FIG. 26 , PROF may not apply to a blockto which BCW or WP applies, for harmonization between BDOF and PROF froma design point of view. For example, when BcwIdx is not 0 or whenluma_weight_lX_flag[refIdxLX] (X being 0 or 1) is 1, cbProfFlagLX may beset to a second value (“False” or “0”). BcwIdx being not 0 may mean thatBCW applies to the current block, and luma_weight_lX_flag[refIdxLX]being 1 may mean that WP in an LX prediction direction applies to thecurrent block. In the present disclosure, BcwIdx being 0 may mean thatan equal weight applies, that is, a bi-prediction block is generated byaverage sum of an L0 prediction block and an L1 prediction block.Accordingly, when cbProfFlagLX is derived, if BCW or WP applies to thecurrent block, control may be performed not to apply PROF, by adding theabove conditions.

FIG. 27 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

According to the embodiment of FIG. 27 , a PROF application conditionmay further include conditions related to resolutions of a currentpicture and a reference picture. PROF is an refining method of aprediction sample considering optical flow similarly to BDOF. Opticalflow is technology of reflecting an offset of motion when a movingobject has the same pixel value and bidirectional movement is constant.Accordingly, when resolutions of the current picture and the referencepicture are different, it is necessary to limit PROF not to beperformed.

As shown in FIG. 27 , when the width pic_width_in_luma_samples of thereference picture is different from that of the current picture or theheight pic_height_in_luma_samples of the reference picture is differentfrom that of the current picture, it is possible to control not to applyPROF to the current block by setting cbProfFlag to a second value(“False” or “0”).

In this case, the reference picture may be a reference picture in aprediction direction of cbProfFlag. Specifically, when cbProfFlagL0 isderived, the size of the L0 reference picture and the size of thecurrent picture may be considered. When the width or height of the L0reference picture is different from that of the current picture,cbProfFlagL0 may be set to a second value and PROF for the L0 predictionsample may not be performed. In addition, when the width and height ofthe L0 reference picture are equal to those of the current picture,cbProfFlagL0 may be set to a first value and PROF applies to the L0prediction sample, thereby generating a refined L0 prediction sample.

Similarly, when cbProfFlagL1 is derived, the size of the L1 referencepicture and the size of the current picture may be considered. When thewidth or height of the L1 reference picture is different from that ofthe current picture, cbProfFlagL1 may be set to a second value and PROFfor the L1 prediction sample may not be performed. In addition, when thewidth and height of the L1 reference picture and the width and height ofthe current picture are the same, cbProfFlagL1 may be set to a firstvalue and PROF applies to the L1 prediction sample, thereby generating arefined L1 prediction sample.

An underlined condition of FIG. 27 may mean a reference pictureresampling (RPR) condition. When the size of the reference picture andthe size of the current picture are different from each other, the RPRcondition may have a first value (“True” or “1”). The RPR condition of afirst value may mean that resampling of the reference picture isnecessary. In addition, when the size of the reference picture and thesize of the current picture are the same, the RPR condition may have asecond value (“False” or “0”). The RPR condition of a second value maymean that resampling of the reference picture is not necessary. That is,when the RPR is a first value, PROF may not apply.

FIG. 28 is a view illustrating a method of performing PROF according tothe present disclosure.

The method of FIG. 28 may be performed by the inter prediction unit 180of the image encoding apparatus or the inter prediction unit 260 of theimage decoding apparatus. More specifically, the method of FIG. 28 maybe performed by the prediction sample derivation unit 183 in the interprediction unit 180 of the image encoding apparatus or the predictionsample derivation unit 263 in the inter prediction unit 260 of the imagedecoding apparatus.

According to FIG. 28 , motion information of a current block may bedetermined (S2810). The motion information of the current block may bedetermined based on various methods described in the present disclosure.The image encoding apparatus may determine optimal motion information asthe motion information of the current block, by calculatingrate-distortion (RD) cost based on various inter prediction modes andmotion information. The image encoding apparatus may encode thedetermined inter prediction mode and motion information in a bitstream.The image decoding apparatus may determine (derive) the motioninformation of the current block by decoding information signaledthrough the bitstream.

Based on the motion information of the current block determined in stepS2810, prediction samples (prediction block) of the current block may bederived (S2820). The prediction samples of the current block may bederived based on various methods described in the present disclosure.

In step S2830, a reference picture resampling (RPR) condition for thecurrent block may be derived. For example, when the width or height of areference picture of the current block is different from that of acurrent picture, the RPR condition may be set to a first value (“True”or “1”). In addition, when the width and height of the reference pictureof the current block are respectively equal to those of the currentpicture, the RPR condition may be set to a second value (“False” or“0”).

Information cbProfFlag specifying whether PROF applies to the currentblock may be derived based on the RPR condition (S2840). For example,when the RPR condition is a first value, cbProfFlag may be set to asecond value. That is, when the size of the current picture is differentfrom that of the reference picture, it may be determined that PROF doesnot apply. In addition, when the RPR condition is a second value,cbProfFlag may be set to a first value. That is, when the size of thecurrent picture is equal to that of the reference picture, it may bedetermined that PROF applies. Although step S2840 is described asderiving cbProfFlag based on the RPR condition, this is for convenienceof description and a condition for deriving cbProfFlag is not limited tothe RPR condition. That is, in order to derive cbProfFlag, otherconditions described in the present disclosure or other conditions notdescribed in the present disclosure may be considered in addition to theRPR condition.

Based on cbProfFlag derived in step S2840, whether to perform PROF maybe determined (S2850). When cbProfFlag is a first value (“True” or “1”),PROF may be performed with respect to the prediction sample of thecurrent block (S2860). When cbProfFlag is a second value (“False” or“0”), PROF may be skipped without being performed with respect to theprediction sample of the current block.

The PROF process of step S2860 may be performed according to the PROFprocess described in the present disclosure. More specifically, whenPROF applies to the current block, a differential motion vector for eachsample position in the current block may be derived, a gradient for eachsample position in the current block may be derived, a PROF offset maybe derived based on the differential motion vector and the gradient, andthen a refined prediction sample for the current block may be derivedbased on the PROF offset.

The image encoding apparatus may derive a residual sample (residualblock) for the current block based on the refined prediction sample(prediction block) and encode information on the residual sample in abitstream. The image decoding apparatus may reconstruct the currentblock based on the refined prediction sample (prediction block) and theresidual sample (residual block) obtained by decoding the bitstream.

In the example shown in FIG. 28 , the RPR condition of step S2830 is notlimited to being performed after step S2820. For example, it issufficient that the RPR condition is derived before deriving cbProfFlag(S2840), and the embodiment of the present disclosure may includevarious examples of deriving the RPR condition before performing stepS2840.

FIG. 29 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

The embodiment of FIG. 29 is an example of an embodiment in which theembodiment of FIG. 26 and the embodiment of FIG. 27 are combined. Asdescribed above, PROF may not apply to a block, to which BCW or WPapplies, for harmonization between BDOF and PROF from a design point ofview. PROF may apply even in case of uni-directional prediction unlikeBDOF. Accordingly, when WP of uni-directional prediction applies, PROFmay not apply to the current block. In addition, when the size of thereference picture of uni-directional prediction is different from thatof the current picture, PROF may not apply to the current block.

According to FIG. 29 , when WP in an L0 direction applies (e.g.,luma_weight_l0_flag==1) or WP in an L1 direction applies (e.g.,luma_weight_l1_flag==1), cbProfFlag may be set not to apply PROF. Inaddition, when the size of the reference picture in the L0 direction isdifferent from that of the current picture or the size of the referencepicture in the L1 direction is different from that of the currentpicture, cbProfFlag may be set not to apply PROF.

FIG. 30 is a view illustrating a process of determining whether to applyPROF according to another embodiment of the present disclosure.

The embodiment of FIG. 30 is another example of an embodiment in whichthe embodiment of FIG. 26 and the embodiment of FIG. 27 are combined. Asdescribed above, PROF may apply even in un-directional prediction unlikeBDOF. Accordingly, when WP of uni-directional prediction applies, PROFmay not apply for the corresponding direction. In addition, when thesize of the reference picture of uni-directional prediction is differentfrom that of the current picture, PROF may not apply for thecorresponding direction.

According to FIG. 30 , when WP in an L0 direction applies (e.g.,luma_weight_l0_flag==1) or the size of the reference picture in the L0direction is different from that of the current picture, cbProfFlagL0may be set to a second value (“False” or “0”) not to apply PROF in theL0 direction. In addition, when WP in an L1 direction applies (e.g.,luma_weight_l1_flag==1) or the size of the reference picture in the L1direction is different from that of the current picture, cbProfFlagL1may be set to a second value (“False” or “0”) not to apply PROF in theL1 direction.

The various embodiments described in the present disclosure may beimplemented alone or in combination with other embodiments.Alternatively, some of an embodiment may be added to another embodimentor some of an embodiment may be replaced with some of anotherembodiment.

According to the various embodiments described in the presentdisclosure, by matching some of the application conditions of PROF andthe application conditions of BDOF, harmonization between PROF and BDOFfrom a design point of view may be expected and, further, implementationcomplexity may be reduced.

While the exemplary methods of the present disclosure described aboveare represented as a series of operations for clarity of description, itis not intended to limit the order in which the steps are performed, andthe steps may be performed simultaneously or in different order asnecessary. In order to implement the method according to the presentdisclosure, the described steps may further include other steps, mayinclude remaining steps except for some of the steps, or may includeother additional steps except for some steps.

In the present disclosure, the image encoding apparatus or the imagedecoding apparatus that performs a predetermined operation (step) mayperform an operation (step) of confirming an execution condition orsituation of the corresponding operation (step). For example, if it isdescribed that predetermined operation is performed when a predeterminedcondition is satisfied, the image encoding apparatus or the imagedecoding apparatus may perform the predetermined operation afterdetermining whether the predetermined condition is satisfied.

The various embodiments of the present disclosure are not a list of allpossible combinations and are intended to describe representativeaspects of the present disclosure, and the matters described in thevarious embodiments may be applied independently or in combination oftwo or more.

Various embodiments of the present disclosure may be implemented inhardware, firmware, software, or a combination thereof. In the case ofimplementing the present disclosure by hardware, the present disclosurecan be implemented with application specific integrated circuits(ASICs), Digital signal processors (DSPs), digital signal processingdevices (DSPDs), programmable logic devices (PLDs), field programmablegate arrays (FPGAs), general processors, controllers, microcontrollers,microprocessors, etc.

In addition, the image decoding apparatus and the image encodingapparatus, to which the embodiments of the present disclosure areapplied, may be included in a multimedia broadcasting transmission andreception device, a mobile communication terminal, a home cinema videodevice, a digital cinema video device, a surveillance camera, a videochat device, a real time communication device such as videocommunication, a mobile streaming device, a storage medium, a camcorder,a video on demand (VoD) service providing device, an OTT video (over thetop video) device, an Internet streaming service providing device, athree-dimensional (3D) video device, a video telephony video device, amedical video device, and the like, and may be used to process videosignals or data signals. For example, the OTT video devices may includea game console, a blu-ray player, an Internet access TV, a home theatersystem, a smartphone, a tablet PC, a digital video recorder (DVR), orthe like.

FIG. 31 is a view showing a content streaming system, to which anembodiment of the present disclosure is applicable.

As shown in FIG. 31 , the content streaming system, to which theembodiment of the present disclosure is applied, may largely include anencoding server, a streaming server, a web server, a media storage, auser device, and a multimedia input device.

The encoding server compresses contents input from multimedia inputdevices such as a smartphone, a camera, a camcorder, etc. into digitaldata to generate a bitstream and transmits the bitstream to thestreaming server. As another example, when the multimedia input devicessuch as smartphones, cameras, camcorders, etc. directly generate abitstream, the encoding server may be omitted.

The bitstream may be generated by an image encoding method or an imageencoding apparatus, to which the embodiment of the present disclosure isapplied, and the streaming server may temporarily store the bitstream inthe process of transmitting or receiving the bitstream.

The streaming server transmits the multimedia data to the user devicebased on a user's request through the web server, and the web serverserves as a medium for informing the user of a service. When the userrequests a desired service from the web server, the web server maydeliver it to a streaming server, and the streaming server may transmitmultimedia data to the user. In this case, the content streaming systemmay include a separate control server. In this case, the control serverserves to control a command/response between devices in the contentstreaming system.

The streaming server may receive contents from a media storage and/or anencoding server. For example, when the contents are received from theencoding server, the contents may be received in real time. In thiscase, in order to provide a smooth streaming service, the streamingserver may store the bitstream for a predetermined time.

Examples of the user device may include a mobile phone, a smartphone, alaptop computer, a digital broadcasting terminal, a personal digitalassistant (PDA), a portable multimedia player (PMP), navigation, a slatePC, tablet PCs, ultrabooks, wearable devices (e.g., smartwatches, smartglasses, head mounted displays), digital TVs, desktops computer, digitalsignage, and the like.

Each server in the content streaming system may be operated as adistributed server, in which case data received from each server may bedistributed.

The scope of the disclosure includes software or machine-executablecommands (e.g., an operating system, an application, firmware, aprogram, etc.) for enabling operations according to the methods ofvarious embodiments to be executed on an apparatus or a computer, anon-transitory computer-readable medium having such software or commandsstored thereon and executable on the apparatus or the computer.

INDUSTRIAL APPLICABILITY

The embodiments of the present disclosure may be used to encode ordecode an image.

1-15. (canceled)
 16. An image decoding method performed by an imagedecoding apparatus, the image decoding method comprising: deriving aprediction sample of a current block based on motion information of thecurrent block; deriving a reference picture resampling (RPR) conditionfor the current block; determining whether prediction refinement withoptical flow (PROF) applies to the current block based on the RPRcondition; and deriving a refined prediction sample for the currentblock by applying PROF to the current block, wherein the RPR conditionis derived based on a width of the reference picture of the currentblock being different from that of the current picture or a height ofthe reference picture of the current block being different from that ofthe current picture.
 17. The image decoding method of claim 16, whereinthe RPR condition is derived as a first value, based on the width of thereference picture of the current block being different from that of thecurrent picture or the height of the reference picture of the currentblock being different from that of the current picture, and wherein theRPR condition is derived as a second value, based on the width of thereference picture of the current block being equal to that of thecurrent picture and the height of the reference picture of the currentblock being equal to that of the current picture.
 18. The image decodingmethod of claim 17, wherein it is determined that PROF does not apply tothe current block, based on the RPR condition being the first value. 19.The image decoding method of claim 16, wherein whether PROF applies tothe current block is determined based on a size of the current block.20. The image decoding method of claim 19, wherein it is determined thatPROF does not apply to the current block, based on a product of a widthw of the current block and a height h of the current block being lessthan
 128. 21. The image decoding method of claim 16, wherein informationspecifying whether the current block is an affine merge mode is parsedfrom a bitstream based on a size of the current block.
 22. The imagedecoding method of claim 21, wherein the information specifying whetherthe current block is the affine merge mode is parsed from the bitstream,based on each of a width w of the current block and a height h of thecurrent block being equal to or greater than 8 and w*h being equal to orgreater than
 128. 23. The image decoding method of claim 16, whereininformation specifying whether the current block is an affine MVP modeis parsed from a bitstream based on a size of the current block.
 24. Theimage decoding method of claim 23, wherein the information specifyingwhether the current block is the affine MVP mode is parsed from thebitstream, based on each of a width w of the current block and a heighth of the current block being equal to or greater than 8 and w*h beingequal to or greater than
 128. 25. The image decoding method of claim 16,wherein whether PROF applies to the current block is determined based onwhether BCW or WP applies to the current block.
 26. The image decodingmethod of claim 25, wherein it is determined that PROF does not apply tothe current block, based on BCW or WP applying to the current block. 27.An image encoding method performed by an image encoding apparatus, theimage encoding method comprising: deriving a prediction sample of acurrent block based on motion information of the current block; derivinga reference picture resampling (RPR) condition for the current block;determining whether prediction refinement with optical flow (PROF)applies to the current block based on the RPR condition; and deriving arefined prediction sample for the current block by applying PROF to thecurrent block, wherein the RPR condition is derived based on a width ofthe reference picture of the current block being different from that ofthe current picture or a height of the reference picture of the currentblock being different from that of the current picture.
 28. A method oftransmitting a bitstream generated by the image encoding method, theimage encoding method comprising; deriving a prediction sample of acurrent block based on motion information of the current block; derivinga reference picture resampling (RPR) condition for the current block;determining whether prediction refinement with optical flow (PROF)applies to the current block based on the RPR condition; and deriving arefined prediction sample for the current block by applying PROF to thecurrent block, wherein the RPR condition is derived based on a width ofthe reference picture of the current block being different from that ofthe current picture or a height of the reference picture of the currentblock being different from that of the current picture.
 29. Anon-transitory computer readable recording medium storing a bitstreamgenerated by the image encoding method of claim 26.